//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package org.jeecg.modules.jmreport.desreport.service.a;

import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFColor;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
import org.jeecg.modules.jmreport.api.data.IDataSetFactory;
import org.jeecg.modules.jmreport.common.constant.CommonConstant;
import org.jeecg.modules.jmreport.common.constant.JmConst;
import org.jeecg.modules.jmreport.common.expetion.JimuReportException;
import org.jeecg.modules.jmreport.common.util.CommonUtils;
import org.jeecg.modules.jmreport.common.util.ExcelUtil;
import org.jeecg.modules.jmreport.common.util.JimuSpringContextUtils;
import org.jeecg.modules.jmreport.common.util.oConvertUtils;
import org.jeecg.modules.jmreport.common.vo.JmDictModel;
import org.jeecg.modules.jmreport.common.vo.Result;
import org.jeecg.modules.jmreport.config.JmReportBaseConfig;
import org.jeecg.modules.jmreport.config.client.JmReportTokenClient;
import org.jeecg.modules.jmreport.desreport.dao.*;
import org.jeecg.modules.jmreport.desreport.entity.*;
import org.jeecg.modules.jmreport.desreport.express.b;
import org.jeecg.modules.jmreport.desreport.model.*;
import org.jeecg.modules.jmreport.desreport.render.handler.BaseRenderHandler;
import org.jeecg.modules.jmreport.desreport.render.handler.convert.ApiDataConvertAdapter;
import org.jeecg.modules.jmreport.desreport.render.utils.FreeMarkerUtils;
import org.jeecg.modules.jmreport.desreport.render.utils.RegexMatches;
import org.jeecg.modules.jmreport.desreport.render.utils.ReportUtil;
import org.jeecg.modules.jmreport.desreport.service.IJimuReportDictItemService;
import org.jeecg.modules.jmreport.desreport.service.IJimuReportDictService;
import org.jeecg.modules.jmreport.desreport.service.IJimuReportService;
import org.jeecg.modules.jmreport.desreport.service.IJmReportDbFieldService;
import org.jeecg.modules.jmreport.dyndb.JmreportDataSourceCachePool;
import org.jeecg.modules.jmreport.dyndb.JmreportDynamicDbUtil;
import org.jeecg.modules.jmreport.dyndb.JmreportNoSqlUtil;
import org.jeecg.modules.jmreport.dyndb.util.JmreportSqlUtils;
import org.jeecg.modules.jmreport.dyndb.vo.JmreportDynamicDataSourceVo;
import org.jeecgframework.minidao.pojo.MiniDaoPage;
import org.jeecgframework.minidao.util.MiniDaoUtil;
import org.jeecgframework.minidao.util.SnowflakeIdWorker;
import org.jeecgframework.minidao.util.SqlServerParse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Map.Entry;

@Service("jimuReportServiceImpl")
public class e implements IJimuReportService {
    private static final Logger a = LoggerFactory.getLogger(e.class);
    @Autowired
    private JimuReportDbDao reportDbDao;
    @Autowired
    private JimuReportDataSourceDao jimuReportDataSourceDao;
    @Autowired
    private JimuReportDbParamDao dbParamDao;
    @Autowired
    private JimuReportDao reportDao;
    @Autowired
    private JimuReportDbFieldDao dbFieldDao;
    @Autowired
    private JmreportDynamicDbUtil jmreportDynamicDbUtil;
    @Autowired
    private IJimuReportDictService dictService;
    @Autowired
    private IJimuReportDictItemService jimuDictItemService;
    @Autowired
    private IJmReportDbFieldService jmReportDbFieldService;
    @Autowired
    private JmReportTokenClient jimuTokenClient;
    @Autowired
    private JimuReportLinkDao jimuReportLinkDao;
    @Autowired
    Map<String, BaseRenderHandler> renderHandlerMap;
    @Autowired
    private JmReportBaseConfig jmBaseConfig;
    @Autowired
    private MybatisPlusSaasConfig mybatisPlusSaasConfig;
    @Autowired
    private JmreportNoSqlUtil jmreportNoSqlUtil;
    private static int b = 0;
    private static boolean c = false;
    private static boolean d = false;
    private static boolean e = false;
    private static boolean f = false;
    private static boolean g = false;
    private static boolean h = false;

    public e() {
    }

    public String getReportConfigSqlString(String id) {
        StringBuffer var2 = new StringBuffer();
        JimuReport var3 = this.reportDao.get(id);
        String var4 = org.jeecg.modules.jmreport.desreport.util.e.a(var3, JimuReport.class, "jimu_report", (Map)null);
        var2.append(var4);
        List var5 = this.reportDbDao.selectList(id);
        if (var5 != null && var5.size() > 0) {
            Map var6 = org.jeecg.modules.jmreport.desreport.util.e.a(JmReportDb.class);
            Iterator var7 = var5.iterator();

            while(true) {
                String var15;
                List var17;
                do {
                    do {
                        if (!var7.hasNext()) {
                            return var2.toString();
                        }

                        JmReportDb var8 = (JmReportDb)var7.next();
                        String var9 = org.jeecg.modules.jmreport.desreport.util.e.a(var8, JmReportDb.class, "jimu_report_db", var6);
                        var2.append(var9);
                        List var10 = this.dbFieldDao.listByDbId(var8.getId());
                        if (var10 != null && var10.size() > 0) {
                            Map var11 = org.jeecg.modules.jmreport.desreport.util.e.a(JmReportDbField.class);
                            Iterator var12 = var10.iterator();

                            while(var12.hasNext()) {
                                JmReportDbField var13 = (JmReportDbField)var12.next();
                                String var14 = org.jeecg.modules.jmreport.desreport.util.e.a(var13, JmReportDbField.class, "jimu_report_db_field", var11);
                                var2.append(var14);
                                var15 = this.a(var13.getDictCode());
                                var2.append(var15);
                            }
                        }

                        var17 = this.dbParamDao.list(var8.getId());
                    } while(var17 == null);
                } while(var17.size() <= 0);

                Map var18 = org.jeecg.modules.jmreport.desreport.util.e.a(JmReportDbParam.class);
                Iterator var19 = var17.iterator();

                while(var19.hasNext()) {
                    JmReportDbParam var20 = (JmReportDbParam)var19.next();
                    var15 = org.jeecg.modules.jmreport.desreport.util.e.a(var20, JmReportDbParam.class, "jimu_report_db_param", var18);
                    var2.append(var15);
                    String var16 = this.a(var20.getDictCode());
                    var2.append(var16);
                }
            }
        } else {
            return var2.toString();
        }
    }

    private String a(String var1) {
        if (var1 != null && !"".equals(var1)) {
            StringBuffer var2 = new StringBuffer();
            var2.append("\r\n");
            JimuReportDict var3 = this.dictService.getByCode(var1);
            if (var3 != null) {
                String var4 = org.jeecg.modules.jmreport.desreport.util.e.a(var3, JimuReportDict.class, "jimu_dict", (Map)null);
                var2.append(var4);
                List var5 = this.jimuDictItemService.selectItemsByMainId(var3.getId());
                String var6 = org.jeecg.modules.jmreport.desreport.util.e.a(var5, JimuReportDictItem.class, "jimu_dict_item");
                var2.append(var6);
            }

            return var2.toString();
        } else {
            return "";
        }
    }

    public Map<String, Object> getDataById(JimuReport report, JSONObject paramJson, boolean onlyPageData, String excelDbcode) {
        HashMap var5 = new HashMap();
        if (report == null) {
            return var5;
        } else {
            JSONObject var6 = new JSONObject();
            var6.putAll(paramJson);
            List var7 = this.reportDbDao.selectList(report.getId());
            if (var7 == null) {
                return var5;
            } else {
                String var8 = "";
                JSONObject var9 = JSONObject.parseObject(report.getJsonStr());
                JSONArray var10 = null;
                ArrayList var11 = new ArrayList();
                if (var9 != null) {
                    if (var9.containsKey("groupField") && var9.containsKey("isGroup")) {
                        var8 = var9.getString("groupField");
                    }

                    var10 = var9.getJSONArray("dbexps");
                }

                if (var10 != null && var10.size() > 0) {
                    for(int var12 = 0; var12 < var10.size(); ++var12) {
                        String var13 = var10.getString(var12);
                        JmExpression var14 = new JmExpression(var13);
                        var11.add(var14);
                    }
                }

                String var51 = paramJson.getString("printAll");
                var7 = this.c(var7);
                HashMap var52 = new HashMap();
                JSONObject var53 = paramJson.clone();
                Map var15 = this.a(var7, paramJson);
                Iterator var16 = var7.iterator();

                while(true) {
                    JmReportDb var17;
                    do {
                        do {
                            if (!var16.hasNext()) {
                                Map var54 = JmExpression.getExpMapByList(var11);
                                var5.put("expData", var54);
                                var5.put("replaceParams", var6);
                                return var5;
                            }

                            var17 = (JmReportDb)var16.next();
                        } while(onlyPageData && !"1".equals(var17.getIsPage()));
                    } while(oConvertUtils.isNotEmpty(excelDbcode) && !var17.getDbCode().equals(excelDbcode));

                    Object var18 = new ArrayList();
                    String var19 = var17.getDbCode();
                    new JSONObject();
                    paramJson = var53.clone();
                    this.a((JmReportDb)var17, (Map)var52, (Map)var15);
                    this.a(paramJson, var19, var6, var17);
                    ReportDbInfo var21;
                    if ("2".equals(var17.getDbType())) {
                        var21 = this.a((JmReportDb)var17, (JSONObject)paramJson, (List)var18);
                        var5.put(var19, var21);
                    }

                    String var26;
                    String var28;
                    JSONObject var55;
                    if ("0".equals(var17.getDbType())) {
                        var55 = new JSONObject();
                        JSONObject var22 = (JSONObject)var15.get("shared_query_param");
                        JSONObject var23 = (JSONObject)var15.get(var19);
                        var55.putAll(var22);
                        var55.putAll(var23);
                        String var24 = this.getBaseSql(var17, var55);
                        String var25 = this.a(var17, paramJson);
                        this.a((JmReportDb)var17, (String)var24, (String)var25, (List)var11);
                        var26 = null;
                        if (oConvertUtils.isNotEmpty(var8)) {
                            String[] var27 = var8.split(".");
                            if (var27.length == 2 && var19.equals(var27[0])) {
                                var26 = var27[1];
                            }
                        }

                        String var65 = this.a(var24, var25, var26);
                        a.info("------报表【" + var19 + "】，查询的sql: " + var65);
                        var28 = var17.getDbSource();
                        Integer var29 = oConvertUtils.getInt(paramJson.get("pageSize"), 10);
                        Integer var30 = oConvertUtils.getInt(paramJson.get("pageNo"), 1);
                        if (oConvertUtils.isEmpty(var28) && this.jmBaseConfig.getSaas()) {
                            throw new JimuReportException("数据源不允许为空，请选择数据源！");
                        }

                        //是否是存储过程call
                        String var31 = org.jeecg.modules.jmreport.desreport.util.e.f(var65);
                        ReportDbInfo var32;
                        List var33;
                        if (StringUtils.isNotBlank(var31)) {
                            var32 = new ReportDbInfo();
                            var33 = this.jmreportDynamicDbUtil.executeProcedure(var28, var31);
                            if (oConvertUtils.isNotEmpty(var33)) {
                                var33 = ReportUtil.a(var33);
                            }

                            var32.setList(var33);
                            var5.put(var19, var32);
                        } else if (this.jmreportNoSqlUtil.isNoSql(var28)) {
                            var32 = new ReportDbInfo();
                            var33 = this.jmreportNoSqlUtil.findList(var65, var28);
                            if (oConvertUtils.isNotEmpty(var33)) {
                                var33 = ReportUtil.a(var33);
                            }

                            var32.setList(var33);
                            var5.put(var19, var32);
                        } else {
                            String var69;
                            if (oConvertUtils.isNotEmpty(var28)) {
                                a.info("------数据源 dbSourceKey:【" + var28 + "】");
                                if (oConvertUtils.isNotEmpty(var51)) {
                                    var32 = new ReportDbInfo();
                                    Object var71 = new ArrayList();

                                    try {
                                        var71 = this.jmreportDynamicDbUtil.findList(var28, var65, new Object[0]);
                                    } catch (Exception var49) {
                                        a.warn(var49.getMessage(), var49);
                                    }

                                    if (oConvertUtils.isNotEmpty(var71)) {
                                        var71 = ReportUtil.a((List)var71);
                                    }

                                    var32.setList((List)var71);
                                    var5.put(var19, var32);
                                } else {
                                    if (var65.endsWith(";")) {
                                        var65 = var65.substring(0, var65.length() - 1);
                                    }

                                    var69 = JmreportSqlUtils.getCountSql(var65);
                                    new HashMap();

                                    Map var76;
                                    try {
                                        JmreportDynamicDataSourceVo var34 = JmreportDataSourceCachePool.getCacheDynamicDataSourceModel(var28);
                                        if ("sqlserver".equals(var34.getDbType().toLowerCase()) && !var69.toUpperCase().contains("CONVERT")) {
                                            SqlServerParse var35 = new SqlServerParse();
                                            var69 = var35.removeOrderBy(var69);
                                        }

                                        var76 = (Map)this.jmreportDynamicDbUtil.findOne(var28, var69, new Object[0]);
                                    } catch (Exception var50) {
                                        a.warn(var50.getMessage(), var50);
                                        throw new JimuReportException(var50.getMessage());
                                    }

                                    int var70 = 1;
                                    Object var73 = var76.get("total");
                                    int var36 = 0;
                                    if (var73 != null) {
                                        var36 = Integer.parseInt(var73.toString());
                                        double var37 = Double.parseDouble(var73.toString()) / (double)var29;
                                        var70 = (int)Math.ceil(var37);
                                    }

                                    List var78 = null;
                                    if ("1".equals(var17.getIsPage())) {
                                        JmreportDynamicDataSourceVo var38 = JmreportDataSourceCachePool.getCacheDynamicDataSourceModel(var28);
                                        String var39 = MiniDaoUtil.createPageSql(var38.getDbUrl(), var65, var30, var29);

                                        try {
                                            var78 = this.jmreportDynamicDbUtil.findList(var28, var39, new Object[0]);
                                        } catch (Exception var48) {
                                            a.warn(var48.getMessage(), var48);
                                            throw new JimuReportException(var48.getMessage());
                                        }
                                    } else {
                                        try {
                                            var78 = this.jmreportDynamicDbUtil.findList(var28, var65, new Object[0]);
                                        } catch (Exception var47) {
                                            a.warn(var47.getMessage(), var47);
                                            throw new JimuReportException(var47.getMessage());
                                        }
                                    }

                                    ReportDbInfo var80 = new ReportDbInfo((long)var70, (long)var36, var17.getIsPage(), var17.getIsList(), var17.getDbType());
                                    if (oConvertUtils.isNotEmpty(var78)) {
                                        var78 = ReportUtil.a(var78);
                                    }

                                    var80.setList(var78);
                                    var5.put(var19, var80);
                                }
                            } else if (oConvertUtils.isNotEmpty(var51)) {
                                var32 = new ReportDbInfo();
                                new ArrayList();

                                try {
                                    var33 = this.reportDbDao.selectListBySql(var65);
                                } catch (Exception var46) {
                                    a.warn(var46.getMessage(), var46);
                                    throw new JimuReportException(var46.getMessage());
                                }

                                if (oConvertUtils.isNotEmpty(var33)) {
                                    var33 = ReportUtil.a(var33);
                                }

                                var32.setList(var33);
                                var5.put(var19, var32);
                            } else {
                                var69 = var17.getIsPage();
                                String var79 = var17.getIsList();
                                if ("0".equals(var69) || oConvertUtils.isEmpty(var69)) {
                                    var30 = 1;
                                }

                                ReportDbInfo var72 = null;
                                if ("1".equals(var69)) {
                                    new MiniDaoPage();

                                    MiniDaoPage var74;
                                    try {
                                        var74 = this.reportDbDao.selectPageBySql(var65, var30, var29);
                                    } catch (Exception var45) {
                                        a.warn(var45.getMessage(), var45);
                                        throw new JimuReportException(var45.getMessage());
                                    }

                                    var72 = new ReportDbInfo((long)var74.getPages(), (long)var74.getTotal(), var69, var79, var17.getDbType());
                                    List var77 = var74.getResults();
                                    if (oConvertUtils.isNotEmpty(var77)) {
                                        var77 = ReportUtil.a(var77);
                                    }

                                    var72.setList(var77);
                                } else {
                                    new ArrayList();

                                    List var75;
                                    try {
                                        var75 = this.reportDbDao.selectListBySql(var65);
                                    } catch (Exception var44) {
                                        a.warn(var44.getMessage(), var44);
                                        throw new JimuReportException(var44.getMessage());
                                    }

                                    if (var75 != null) {
                                        var72 = new ReportDbInfo(1L, (long)var75.size(), var69, var79, var17.getDbType());
                                        if (oConvertUtils.isNotEmpty(var75)) {
                                            var75 = ReportUtil.a(var75);
                                        }

                                        var72.setList(var75);
                                    }
                                }

                                var5.put(var19, var72);
                            }
                        }

                        var32 = (ReportDbInfo)var5.get(var19);
                        var33 = var32.getList();
                        var18 = oConvertUtils.deepCopy(var33);
                        this.replaceDbCode(var17, var33);
                        var32.setList(var33);
                        var5.replace(var19, var32);
                    }

                    if ("1".equals(var17.getDbType())) {
                        var55 = this.a(var17, var15, var51, var8);
                        String var56 = this.jimuTokenClient.getToken();
                        Object var58 = new HashMap();

                        try {
                            var58 = this.a(var17, var56, var55);
                        } catch (ResourceAccessException var41) {
                            throw new JimuReportException("api连接超时，请重试！");
                        } catch (JimuReportException var42) {
                            throw new JimuReportException(var42.getMessage());
                        } catch (Exception var43) {
                            a.warn(var43.getMessage(), var43);
                        }

                        ReportDbInfo var60 = new ReportDbInfo(var17.getIsPage(), var17.getIsList(), var17.getDbType());
                        Object var62 = ((Map)var58).get("dataList");
                        if (oConvertUtils.isNotEmpty(var62)) {
                            var60.setList((List)var62);
                        }

                        if (oConvertUtils.isEmpty(var51)) {
                            Object var64 = ((Map)var58).get("linkList");
                            if (oConvertUtils.isNotEmpty(var64)) {
                                var60.setLinkList((List)var64);
                            }

                            var60.setTotal(CommonUtils.getLong(((Map)var58).get("total"), 0L));
                            var60.setCount(CommonUtils.getLong(((Map)var58).get("count"), 0L));
                        }

                        if (null != var60.getList()) {
                            List var66 = var60.getList();
                            var18 = oConvertUtils.deepCopy(var66);
                            this.replaceDbCode(var17, var66);
                            var60.setList(var66);
                        }

                        var5.put(var19, var60);
                    }

                    if ("3".equals(var17.getDbType())) {
                        var21 = this.a(var17, paramJson, var51, var19);
                        var18 = oConvertUtils.deepCopy(var21.getList());
                        var5.put(var19, var21);
                    }

                    var21 = (ReportDbInfo)var5.get(var19);
                    List var57 = var21.getList();

                    for(int var59 = 0; var59 < var57.size(); ++var59) {
                        Map var61 = (Map)var57.get(var59);
                        Iterator var63 = var61.keySet().iterator();

                        while(var63.hasNext()) {
                            var26 = (String)var63.next();
                            Object var67 = var61.get(var26);
                            if (var67 != null) {
                                var28 = var67.toString();
                                if (var28.indexOf("\"") >= 0) {
                                    String var68 = var28.replaceAll("\"", "\\\\\"");
                                    var61.put(var26, var68);
                                }
                            }
                        }
                    }

                    this.a((JmReportDb)var17, (Map)var52, (List)var18);
                }
            }
        }
    }

    public void a(JSONObject var1, String var2, JSONObject var3, JmReportDb var4) {
        List var5 = this.dbFieldDao.listByDbIdNotNull(var4.getId());
        Iterator var6 = var1.keySet().iterator();

        label55:
        while(true) {
            String var7;
            String var8;
            Object var9;
            do {
                do {
                    if (!var6.hasNext()) {
                        return;
                    }

                    var7 = (String)var6.next();
                    var8 = var2 + "__";
                } while(!var7.contains(var8));

                var9 = var1.get(var7);
            } while(!oConvertUtils.isNotEmpty(var9));

            String var10 = var7.replace(var8, "");
            String var11 = "";
            Iterator var12 = var5.iterator();

            while(true) {
                List var14;
                do {
                    if (!var12.hasNext()) {
                        if (oConvertUtils.isNotEmpty(var11)) {
                            var3.put(var10, var11.substring(0, var11.lastIndexOf(",")));
                        } else {
                            var3.put(var10, var9);
                        }
                        continue label55;
                    }

                    JmReportDbField var13 = (JmReportDbField)var12.next();
                    var14 = null;
                    String var15 = org.jeecg.modules.jmreport.desreport.util.e.a(var13.getDictCode(), (Map)null, this.jmBaseConfig.getApiBasePath());
                    if (var15.contains("http")) {
                        var13.setDictCode(var15);
                        var14 = this.a(var13);
                    } else {
                        var14 = this.getDictListByCode(var13, var4.getDbSource());
                    }

                    new ArrayList();
                } while(null == var14);

                String var17 = String.valueOf(var9);
                String[] var18 = var17.split(",");
                String[] var19 = var18;
                int var20 = var18.length;

                for(int var21 = 0; var21 < var20; ++var21) {
                    String var22 = var19[var21];
                    //List var16 = (List)var14.stream().filter((var1x) -> {
                    //    return var22.equals(var1x.getValue());
                    //}).collect(Collectors.toList());
                    //if (var16.size() > 0) {
                    //    var11 = var11 + ((JmDictModel)var16.get(0)).getText() + ",";
                    //}
                }
            }
        }
    }

    public void a(JmReportDb var1, Map<String, Object> var2, Map<String, JSONObject> var3) {
        String var4 = var1.getJimuReportId();
        String var5 = var1.getDbCode();
        List var6 = this.jimuReportLinkDao.getLinkDataByReportId(var1.getJimuReportId());
        if (null != var6 && var6.size() > 0) {
            Iterator var7 = var6.iterator();

            while(true) {
                JSONArray var11;
                String var12;
                String var13;
                do {
                    JSONObject var10;
                    do {
                        do {
                            JimuReportLink var8;
                            Object var9;
                            do {
                                do {
                                    if (!var7.hasNext()) {
                                        return;
                                    }

                                    var8 = (JimuReportLink)var7.next();
                                    var9 = var8.getParameter();
                                } while(null == var9);
                            } while(!"4".equals(var8.getLinkType()));

                            var10 = JSONObject.parseObject(var9.toString());
                        } while(null == var10);
                    } while(!var10.containsKey("subReport"));

                    var11 = var10.getJSONArray("subReport");
                    var12 = var10.getString("sub");
                    var13 = var10.getString("main");
                } while(!var5.equals(var12));

                for(int var14 = 0; var14 < var11.size(); ++var14) {
                    JSONObject var15 = var11.getJSONObject(var14);
                    if (var15.containsKey("subParam")) {
                        String var16 = var15.getString("subParam");
                        String var17 = var15.getString("mainField");
                        String var18 = var13 + "_" + var17;
                        Map var19 = (Map)var2.get(var18);
                        if (oConvertUtils.isNotEmpty(var19)) {
                            Object var20 = var19.get(var17);
                            JSONObject var21 = (JSONObject)var3.get(var5);
                            var21.put(var16, var20);
                            var3.put(var5, var21);
                        }
                    }
                }
            }
        }
    }

    private List<JmReportDb> c(List<JmReportDb> var1) {
        ArrayList var2 = new ArrayList();
        ArrayList var3 = new ArrayList();
        if (var1.size() > 0) {
            JmReportDb var4 = (JmReportDb)var1.get(0);
            List var5 = this.jimuReportLinkDao.getLinkDataByReportId(var4.getJimuReportId());
            if (null == var5 && var5.size() == 0) {
                return var1;
            }

            Iterator var6 = var1.iterator();

            JmReportDb var7;
            while(var6.hasNext()) {
                var7 = (JmReportDb)var6.next();
                boolean var8 = false;
                Iterator var9 = var5.iterator();

                while(var9.hasNext()) {
                    JimuReportLink var10 = (JimuReportLink)var9.next();
                    Object var11 = var10.getParameter();
                    if (null != var11 && "4".equals(var10.getLinkType())) {
                        JSONObject var12 = JSONObject.parseObject(var11.toString());
                        String var13 = var12.getString("main");
                        if (var13.equals(var7.getDbCode())) {
                            var8 = true;
                        }
                    }
                }

                if (var8) {
                    var2.add(var7);
                } else {
                    var3.add(var7);
                }
            }

            if (null != var2 && var2.size() > 0) {
                var6 = var3.iterator();

                while(var6.hasNext()) {
                    var7 = (JmReportDb)var6.next();
                    var2.add(var7);
                }

                return var2;
            }
        }

        return var1;
    }

    private void a(JmReportDb var1, Map<String, Object> var2, List<Map<String, Object>> var3) {
        String var4 = var1.getDbCode();
        String var5 = var1.getJimuReportId();
        List var6 = this.jimuReportLinkDao.getLinkDataByReportId(var5);
        Iterator var7 = var6.iterator();

        while(true) {
            JSONObject var10;
            String var11;
            do {
                do {
                    do {
                        JimuReportLink var8;
                        Object var9;
                        do {
                            do {
                                if (!var7.hasNext()) {
                                    return;
                                }

                                var8 = (JimuReportLink)var7.next();
                                var9 = var8.getParameter();
                            } while(null == var9);
                        } while(!"4".equals(var8.getLinkType()));

                        var10 = JSONObject.parseObject(var9.toString());
                    } while(null == var10);
                } while(!var10.containsKey("subReport"));

                var11 = var10.getString("main");
            } while(!var11.equals(var4));

            JSONArray var12 = var10.getJSONArray("subReport");

            for(int var13 = 0; var13 < var12.size(); ++var13) {
                JSONObject var14 = var12.getJSONObject(var13);
                if (var14.containsKey("mainField")) {
                    String var15 = var14.getString("mainField");
                    if (oConvertUtils.isNotEmpty(var3)) {
                        Object var16 = var3.get(0);
                        var2.put(var4 + "_" + var15, var16);
                    }
                }
            }
        }
    }

    public ReportDbInfo a(JmReportDb var1, JSONObject var2, String var3, String var4) {
        String var5 = var1.getIsPage();
        Iterator var6 = var2.keySet().iterator();

        JSONObject var7;
        String var8;
        String var9;
        for(var7 = new JSONObject(); var6.hasNext(); var7.put(var8, var9)) {
            var8 = (String)var6.next();
            var9 = var2.getString(var8);
            if (var8.contains(var4)) {
                var8 = var8.replace(var4 + "__", "");
            }
        }

        List var18 = this.dbFieldDao.listByDbId(var1.getId());
        HashMap var19 = new HashMap();
        if (var18 != null && var18.size() > 0) {
            Iterator var10 = var18.iterator();

            while(var10.hasNext()) {
                JmReportDbField var11 = (JmReportDbField)var10.next();
                Integer var12 = var11.getSearchFlag();
                if (JmConst.DB_SEARCH_1 == var11.getSearchFlag()) {
                    var19.put(var11.getFieldName(), var11);
                }
            }
        }

        ReportDbInfo var15 = new ReportDbInfo(var1.getIsPage(), var1.getIsList(), var1.getDbType());
        String var16 = var1.getJsonData();
        JSONObject var17 = JSONObject.parseObject(var16);
        Object var13 = var17.get("data");
        Map var14 = a((Object)var13, (JSONObject)var7, (Map)var19);
        var15.setList((List)var14.get("pageList"));
        return var15;
    }

    public static Map<String, Object> a(Object var0, JSONObject var1, Map<String, JmReportDbField> var2) {
        HashMap var3 = new HashMap();
        List var4 = (List)var0;
        ArrayList var5 = new ArrayList();
        Iterator var6 = var4.iterator();

        while(var6.hasNext()) {
            Map var7 = (Map)var6.next();
            boolean var8 = true;
            var8 = a(var1, var2, var7);
            if (var8) {
                var5.add(var7);
            }
        }

        var3.put("pageList", var5);
        return var3;
    }

    public static boolean a(JSONObject var0, Map<String, JmReportDbField> var1, Map<String, Object> var2) {
        Iterator var3 = var2.entrySet().iterator();

        Integer var11;
        String var14;
        String var15;
        do {
            do {
                while(true) {
                    Object var5;
                    Object var7;
                    JmReportDbField var8;
                    Object var9;
                    Object var10;
                    do {
                        do {
                            String var6;
                            do {
                                if (!var3.hasNext()) {
                                    return true;
                                }

                                Entry var4 = (Entry)var3.next();
                                var5 = var4.getValue();
                                var6 = (String)var4.getKey();
                                var7 = var0.get(var6);
                            } while((null == var7 || !var0.containsKey(var6)) && !var0.containsKey(var6 + "_begin"));

                            var8 = (JmReportDbField)var1.get(var6);
                            var9 = var0.get(var6 + "_begin");
                            var10 = var0.get(var6 + "_end");
                        } while(null == var8);
                    } while(null == var5);

                    var11 = var8.getSearchMode();
                    String var12 = var8.getWidgetType();
                    String var13 = var8.getDictCode();
                    var14 = String.valueOf(var5);
                    var15 = String.valueOf(var7);
                    if (oConvertUtils.isNotEmpty(var13)) {
                        break;
                    }

                    if ((1 == var11 || 3 == var11) && !var14.equals(var15)) {
                        return false;
                    }

                    if (2 == var11) {
                        String var16 = String.valueOf(var9);
                        String var17 = String.valueOf(var10);
                        if (!"number".equals(var12) && var16.compareTo(var14) < 0 && var14.compareTo(var17) > 0) {
                            return false;
                        }

                        if ("number".equals(var12)) {
                            Double var18 = Double.valueOf(var14);
                            Double var19 = Double.valueOf(var16);
                            Double var20 = Double.valueOf(var17);
                            if (var19 < var18 && var18 > var20) {
                                return false;
                            }
                        }
                    }
                }
            } while(1 != var11 && 2 != var11 && 3 != var11);
        } while(var14.equals(var15));

        return false;
    }

    public Map importExcel(MultipartFile file) throws IOException {
        InputStream var2 = file.getInputStream();
        Workbook var3 = WorkbookFactory.create(var2);
        Sheet var4 = var3.getSheetAt(0);
        IdentityHashMap var5 = new IdentityHashMap();
        ArrayList var6 = new ArrayList();
        IdentityHashMap var7 = new IdentityHashMap();
        ArrayList var8 = new ArrayList();
        ArrayList var9 = new ArrayList();
        HashMap var10 = new HashMap();
        int var11 = 0;
        Iterator var12 = var4.iterator();

        while(var12.hasNext()) {
            Row var13 = (Row)var12.next();
            int var14 = var13.getRowNum();
            IdentityHashMap var15 = new IdentityHashMap();
            IdentityHashMap var16 = new IdentityHashMap();
            Iterator var17 = var13.iterator();

            while(var17.hasNext()) {
                Cell var18 = (Cell)var17.next();
                String var19 = "";
                IdentityHashMap var20 = new IdentityHashMap();
                IdentityHashMap var21 = new IdentityHashMap();
                int var26;
                MergedResult var28;
                int[] var29;
                CellStyle var30;
                Object var31;
                if (var18.getCellTypeEnum() == CellType.BLANK) {
                    var26 = var18.getColumnIndex();
                    var28 = this.a(var4, var14, var26, var8);
                    if (var28.isMerged()) {
                        var29 = new int[0];
                        var29 = new int[]{var28.getEndRow() - var28.getStartRow(), var28.getEndCol() - var28.getStartCol()};
                        if (!var9.contains(var29[0] + "," + var29[1])) {
                            var20.put("merge", var29);
                            var9.add(var29[0] + "," + var29[1]);
                        }
                    }

                    if (!var28.isMerged()) {
                        var30 = var18.getCellStyle();
                        var31 = new HashMap();
                        if (var30 instanceof XSSFCellStyle) {
                            var31 = this.a((XSSFCellStyle)var30, var18, var28.isMerged());
                        }

                        if (var30 instanceof HSSFCellStyle) {
                            var31 = this.a((HSSFCellStyle)var30, var18, var28.isMerged(), (HSSFWorkbook)var3);
                        }

                        var6.add(var31);
                        var20.put("styles", var11);
                        var16.put(var26, var20);
                        ++var11;
                    }
                } else {
                    switch(var18.getCellTypeEnum()) {
                    case STRING:
                        if (oConvertUtils.isNotEmpty(var18.getRichStringCellValue().getString())) {
                            var20.put("text", var18.getRichStringCellValue().getString());
                        }
                        break;
                    case NUMERIC:
                        String var22 = var18.getCellStyle().getDataFormatString();
                        if (!DateUtil.isCellDateFormatted(var18) && "General".equals(var22)) {
                            var19 = "number";
                            BigDecimal var27 = new BigDecimal(var18.getNumericCellValue());
                            var20.put("text", var27.toPlainString());
                        } else {
                            Date var23 = var18.getDateCellValue();
                            String var24 = this.a(var22, var23, var19);
                            var20.put("text", var24);
                        }
                        break;
                    case BOOLEAN:
                        var20.put("text", var18.getRichStringCellValue());
                    }

                    var26 = var18.getColumnIndex();
                    var28 = this.a(var4, var14, var26, var8);
                    if (var28.isMerged()) {
                        var29 = new int[0];
                        var29 = new int[]{var28.getEndRow() - var28.getStartRow(), var28.getEndCol() - var28.getStartCol()};
                        String var25 = var28.getEndRow() + "," + var28.getStartRow() + "," + var28.getEndCol() + "," + var28.getStartCol();
                        if (!var9.contains(var25)) {
                            var20.put("merge", var29);
                            var9.add(var25);
                        }
                    }

                    var30 = var18.getCellStyle();
                    var31 = new HashMap();
                    if (var30 instanceof XSSFCellStyle) {
                        var31 = this.a((XSSFCellStyle)var30, var18, var28.isMerged());
                    }

                    if (var30 instanceof HSSFCellStyle) {
                        var31 = this.a((HSSFCellStyle)var30, var18, var28.isMerged(), (HSSFWorkbook)var3);
                    }

                    if (oConvertUtils.isNotEmpty(var19)) {
                        ((Map)var31).put("format", var19);
                    }

                    var6.add(var31);
                    var21.put("width", (int)var4.getColumnWidthInPixels(var26));
                    var10.put(var26, var21);
                    var20.put("style", var11);
                    var16.put(var26, var20);
                    ++var11;
                }

                var5.put("styles", var6);
                var15.put("cells", var16);
                var15.put("height", (double)var13.getHeightInPoints() + 9.5D);
            }

            if (oConvertUtils.isNotEmpty(var15)) {
                var7.put(var14, var15);
            }

            var5.put("rows", var7);
            var5.put("merges", var8);
            var5.put("cols", var10);
        }

        return var5;
    }

    private Map<String, Object> a(HSSFCellStyle var1, Cell var2, boolean var3, HSSFWorkbook var4) {
        HashMap var5 = new HashMap();
        HashMap var6 = new HashMap();
        HashMap var7 = new HashMap();
        String var8 = ((HSSFCell)var2).getCellStyle().getFont(var4).getFontName();
        if (oConvertUtils.isNotEmpty(var8)) {
            var7.put("name", var8);
        }

        if (((HSSFCell)var2).getCellStyle().getFont(var4).getBold()) {
            var7.put("bold", true);
        }

        if (((HSSFCell)var2).getCellStyle().getFont(var4).getItalic()) {
            var7.put("italic", true);
        }

        if (((HSSFCell)var2).getCellStyle().getFont(var4).getStrikeout()) {
            var5.put("strike", true);
        }

        byte var9 = ((HSSFCell)var2).getCellStyle().getFont(var4).getUnderline();
        if (var9 > 0) {
            var5.put("underline", true);
        }

        if (((HSSFCell)var2).getCellStyle().getFont(var4).getBold()) {
            var7.put("bold", true);
        }

        var7.put("size", ((HSSFCell)var2).getCellStyle().getFont(var4).getFontHeightInPoints());
        short var10;
        String var11;
        String[] var12;
        if (var1.getBorderBottomEnum() == BorderStyle.THIN) {
            var10 = var1.getBottomBorderColor();
            var11 = this.a(var10, var4);
            var12 = new String[]{"thin", var11};
            var6.put("bottom", var12);
        }

        if (var1.getBorderLeftEnum() == BorderStyle.THIN) {
            var10 = var1.getLeftBorderColor();
            var11 = this.a(var10, var4);
            var12 = new String[]{"thin", var11};
            var6.put("left", var12);
        }

        if (var1.getBorderRightEnum() == BorderStyle.THIN) {
            var10 = var1.getRightBorderColor();
            var11 = this.a(var10, var4);
            var12 = new String[]{"thin", var11};
            var6.put("right", var12);
        }

        if (var1.getBorderTopEnum() == BorderStyle.THIN) {
            var10 = var1.getTopBorderColor();
            var11 = this.a(var10, var4);
            var12 = new String[]{"thin", var11};
            var6.put("top", var12);
        }

        if (var1.getAlignmentEnum() == HorizontalAlignment.CENTER) {
            var5.put("align", "center");
        }

        if (var1.getBorderBottomEnum() == BorderStyle.THIN && var1.getBorderLeftEnum() == BorderStyle.THIN && var1.getBorderTopEnum() == BorderStyle.THIN && var3) {
            var10 = var1.getLeftBorderColor();
            var11 = this.a(var10, var4);
            var12 = new String[]{"thin", var11};
            var6.put("right", var12);
        }

        if (var1.getBorderRightEnum() != BorderStyle.NONE || var1.getBorderBottomEnum() != BorderStyle.NONE || var1.getBorderLeftEnum() != BorderStyle.NONE || var1.getBorderTopEnum() != BorderStyle.NONE) {
            var5.put("border", var6);
        }

        HSSFFont var15 = ((HSSFCell)var2).getCellStyle().getFont(var4);
        short var16 = var15.getColor();
        String var17 = this.a(var16, var4);
        var5.put("color", var17);
        short var13 = var1.getFillForegroundColor();
        String var14 = "";
        if (var13 == 64) {
            var14 = "#ffffff";
        } else {
            var14 = this.a(var13, var4);
        }

        var5.put("bgcolor", var14);
        var5.put("font", var7);
        return var5;
    }

    private String a(String var1, Date var2, String var3) {
        String var4 = "";
        if ("yyyy\"年\"m\"月\"d\"日\";@".equals(var1)) {
            var4 = ExcelUtil.dateformat(var2, "yyyy年MM月dd日");
            var3 = "date2";
        } else if ("yyyy/m/d;@".equals(var1)) {
            var4 = ExcelUtil.dateformat(var2, "yyyy/MM/dd");
            var3 = "date";
        } else if ("h:mm:ss;@".equals(var1)) {
            var4 = ExcelUtil.dateformat(var2, "HH:mm:ss");
            var3 = "time";
        } else if ("yyyy/m/d\\ h:mm:ss".equals(var1)) {
            var4 = ExcelUtil.dateformat(var2, "yyyy/MM/dd HH:mm:ss");
            var3 = "datetime";
        } else {
            if (var1.contains("y")) {
                var3 = var3 + "yyyy";
            }

            if (var1.contains("m")) {
                int var5 = ExcelUtil.sameNumber(var1, "m");
                if (var5 == 1 || var5 == 3) {
                    if (oConvertUtils.isNotEmpty(var3)) {
                        var3 = var3 + "-MM";
                    } else {
                        var3 = var3 + "MM";
                    }
                }
            }

            if (var1.contains("d")) {
                var3 = var3 + "-dd";
            }

            if (var1.contains("h")) {
                var3 = var3 + " HH";
            }

            if (var1.contains("mm")) {
                if (oConvertUtils.isNotEmpty(var3)) {
                    var3 = var3 + ":mm";
                } else {
                    var3 = var3 + "mm";
                }
            }

            if (var1.contains("s")) {
                var3 = var3 + ":ss";
            }

            var4 = ExcelUtil.dateformat(var2, var3);
        }

        return var4;
    }

    private Map<String, Object> a(XSSFCellStyle var1, Cell var2, boolean var3) {
        HashMap var4 = new HashMap();
        HashMap var5 = new HashMap();
        HashMap var6 = new HashMap();
        String var7 = ((XSSFCell)var2).getCellStyle().getFont().getFontName();
        if (oConvertUtils.isNotEmpty(var7)) {
            var6.put("name", var7);
        }

        if (((XSSFCell)var2).getCellStyle().getFont().getBold()) {
            var6.put("bold", true);
        }

        if (((XSSFCell)var2).getCellStyle().getFont().getItalic()) {
            var6.put("italic", true);
        }

        if (((XSSFCell)var2).getCellStyle().getFont().getStrikeout()) {
            var4.put("strike", true);
        }

        byte var8 = ((XSSFCell)var2).getCellStyle().getFont().getUnderline();
        if (var8 > 0) {
            var4.put("underline", true);
        }

        var6.put("size", ((XSSFCell)var2).getCellStyle().getFont().getFontHeightInPoints());
        XSSFColor var9;
        String var10;
        String[] var11;
        if (var1.getBorderBottomEnum() == BorderStyle.THIN) {
            var9 = var1.getBottomBorderXSSFColor();
            var10 = this.a(var9);
            var11 = new String[]{"thin", var10};
            var5.put("bottom", var11);
        }

        if (var1.getBorderLeftEnum() == BorderStyle.THIN) {
            var9 = var1.getLeftBorderXSSFColor();
            var10 = this.a(var9);
            var11 = new String[]{"thin", var10};
            var5.put("left", var11);
        }

        if (var1.getBorderRightEnum() == BorderStyle.THIN) {
            var9 = var1.getLeftBorderXSSFColor();
            var10 = this.a(var9);
            var11 = new String[]{"thin", var10};
            var5.put("right", var11);
        }

        if (var1.getBorderTopEnum() == BorderStyle.THIN) {
            var9 = var1.getLeftBorderXSSFColor();
            var10 = this.a(var9);
            var11 = new String[]{"thin", var10};
            var5.put("top", var11);
        }

        if (var1.getAlignmentEnum() == HorizontalAlignment.CENTER) {
            var4.put("align", "center");
        }

        if (var1.getBorderBottomEnum() == BorderStyle.THIN && var1.getBorderLeftEnum() == BorderStyle.THIN && var1.getBorderTopEnum() == BorderStyle.THIN && var3) {
            var9 = var1.getLeftBorderXSSFColor();
            var10 = this.a(var9);
            var11 = new String[]{"thin", var10};
            var5.put("right", var11);
        }

        if (var1.getBorderRightEnum() != BorderStyle.NONE || var1.getBorderBottomEnum() != BorderStyle.NONE || var1.getBorderLeftEnum() != BorderStyle.NONE || var1.getBorderTopEnum() != BorderStyle.NONE) {
            var4.put("border", var5);
        }

        XSSFFont var14 = ((XSSFCell)var2).getCellStyle().getFont();
        XSSFColor var15;
        byte[] var16;
        if (var14.getXSSFColor() != null) {
            var15 = var14.getXSSFColor();
            var16 = var15.getRGB();
            if (var16.length > 2) {
                String var12 = String.format("#%02X%02X%02X", var16[0], var16[1], var16[2]);
                var4.put("color", var12);
            }
        }

        var15 = var1.getFillForegroundXSSFColor();
        if (null != var15) {
            var16 = var15.getRGB();
            if (null != var16) {
                (new StringBuilder()).append("#").append(String.format("%02X", var16[0])).append(String.format("%02X", var16[1])).append(String.format("%02X", var16[2])).toString();
                String var13 = this.a(var15);
                var4.put("bgcolor", var13);
            }
        }

        var4.put("font", var6);
        return var4;
    }

    public String a(short var1, HSSFWorkbook var2) {
        HSSFColor var3 = var2.getCustomPalette().getColor(var1);
        if (var3 != null) {
            short[] var4 = var3.getTriplet();
            if (var4.length == 3) {
                String var5 = "#" + String.format("%02X", var4[0]) + String.format("%02X", var4[1]) + String.format("%02X", var4[2]);
                return var5;
            } else {
                return "#000000";
            }
        } else {
            return "#000000";
        }
    }

    public String a(XSSFColor var1) {
        if (var1 != null) {
            byte[] var2 = var1.getRGB();
            if (null != var2) {
                String var3 = "#" + String.format("%02X", var2[0]) + String.format("%02X", var2[1]) + String.format("%02X", var2[2]);
                return var3;
            } else {
                return "#000000";
            }
        } else {
            return "#000000";
        }
    }

    public boolean excelQueryName(JimuReport design) {
        boolean var2 = false;
        Integer var3 = 0;
        if (oConvertUtils.isNotEmpty(design.getId())) {
            JimuReport var4 = this.reportDao.get(design.getId());
            if (null != var4 && var4.getName() != null) {
                if (!var4.getName().equals(design.getName())) {
                    var3 = this.reportDao.excelQueryName(design.getName());
                    if (var3 == 0) {
                        var2 = true;
                    }
                } else {
                    var2 = true;
                }
            } else {
                var3 = this.reportDao.excelQueryName(design.getName());
                if (var3 == 0) {
                    var2 = true;
                }
            }
        } else {
            var3 = this.reportDao.excelQueryName(design.getName());
            if (var3 == 0) {
                var2 = true;
            }
        }

        return var2;
    }

    @Transactional(
        rollbackFor = {Exception.class}
    )
    public void reportCopy(JimuReport report) {
        JimuReport var2 = this.reportDao.get(report.getId());
        if (var2 != null) {
            var2.setId(String.valueOf(SnowflakeIdWorker.generateId()));
            String var3 = String.format("%04d", (new Random()).nextInt(9999));
            String var4 = "";
            String var5 = "";
            if (var2.getName().indexOf("副本") == -1) {
                var4 = var2.getCode() + var3;
                var5 = var2.getName() + "副本" + var3;
            } else {
                var4 = var2.getCode().substring(0, 14) + var3;
                var5 = var2.getName().substring(0, var2.getName().indexOf("副本")) + "副本" + var3;
            }

            var2.setName(var5);
            var2.setCode(var4);
            var2.setTemplate(0);
            var2.setCreateBy(report.getCreateBy());
            var2.setCreateTime(report.getCreateTime());
            var2.setViewCount(0L);
            var2.setUpdateTime((Date)null);
            var2.setUpdateBy((String)null);
            this.reportDao.insert(var2);
        }

        List var10 = this.reportDbDao.selectList(report.getId());
        if (var10.size() > 0) {
            Iterator var11 = var10.iterator();

            label45:
            while(true) {
                List var7;
                Iterator var8;
                JmReportDb var12;
                do {
                    if (!var11.hasNext()) {
                        break label45;
                    }

                    var12 = (JmReportDb)var11.next();
                    List var6 = this.dbFieldDao.listByDbId(var12.getId());
                    var7 = this.dbParamDao.list(var12.getId());
                    var12.setId(String.valueOf(SnowflakeIdWorker.generateId()));
                    var12.setJimuReportId(var2.getId());
                    this.reportDbDao.insert(var12);
                    if (var6.size() > 0) {
                        var8 = var6.iterator();

                        while(var8.hasNext()) {
                            JmReportDbField var9 = (JmReportDbField)var8.next();
                            var9.setId(String.valueOf(SnowflakeIdWorker.generateId()));
                            var9.setJimuReportDbId(var12.getId());
                            this.dbFieldDao.insert(var9);
                        }
                    }
                } while(var7.size() <= 0);

                var8 = var7.iterator();

                while(var8.hasNext()) {
                    JmReportDbParam var13 = (JmReportDbParam)var8.next();
                    var13.setId(String.valueOf(SnowflakeIdWorker.generateId()));
                    var13.setJimuReportHeadId(var12.getId());
                    this.dbParamDao.insert(var13);
                }
            }
        }

        this.b(report.getId(), var2.getId());
    }

    private void b(String var1, String var2) {
        List var3 = this.jimuReportLinkDao.getLinkDataByReportId(var1);
        if (!oConvertUtils.isEmptyIterable(var3)) {
            Iterator var4 = var3.iterator();

            while(var4.hasNext()) {
                JimuReportLink var5 = (JimuReportLink)var4.next();
                if ("4".equals(var5.getLinkType())) {
                    var5.setId(String.valueOf(SnowflakeIdWorker.generateId()));
                    var5.setReportId(var2);
                    this.jimuReportLinkDao.insert(var5);
                }
            }
        }

    }

    private MergedResult a(Sheet var1, int var2, int var3, List<String> var4) {
        int var5 = var1.getNumMergedRegions();

        for(int var6 = 0; var6 < var5; ++var6) {
            CellRangeAddress var7 = var1.getMergedRegion(var6);
            int var8 = var7.getFirstColumn();
            int var9 = var7.getLastColumn();
            int var10 = var7.getFirstRow();
            int var11 = var7.getLastRow();
            if (var2 >= var10 && var2 <= var11 && var3 >= var8 && var3 <= var9) {
                String var12 = var7.formatAsString();
                if (!var4.contains(var12)) {
                    var4.add(var12);
                }

                return new MergedResult(true, var10, var11, var8, var9);
            }
        }

        return new MergedResult(false, 0, 0, 0, 0);
    }

    private Map a(JmReportDb var1, String var2, JSONObject var3) {
        String var4 = var1.getApiUrl();
        Object var5 = new HashMap();
        if (oConvertUtils.isNotEmpty(var2)) {
            var5 = this.jimuTokenClient.getUserInfo(var2);
        }

        var4 = org.jeecg.modules.jmreport.desreport.util.e.a(var4, (Map)var5, this.jmBaseConfig.getApiBasePath());
        var4 = org.jeecg.modules.jmreport.desreport.util.e.k(var4);
        a.info("  原始 apiUrl=" + var4 + " , token=" + var2);
        var4 = var4.replaceAll("\\$\\{.*\\}", "");
        a.info("  替换${} apiUrl=" + var4);
        String var6 = "";
        String var9;
        if ("0".equals(var1.getApiMethod())) {
            Iterator var7 = var3.keySet().iterator();

            while(var7.hasNext()) {
                String var8 = (String)var7.next();
                var9 = var3.getString(var8);
                if (var4.indexOf(var8 + "=") < 0) {
                    if (var4.indexOf("?") > 0) {
                        var4 = var4 + "&" + var8 + "=" + var9;
                    } else {
                        var4 = var4 + "?" + var8 + "=" + var9;
                    }
                }
            }

            var4 = org.jeecg.modules.jmreport.desreport.util.e.j(var4);
            var6 = org.jeecg.modules.jmreport.desreport.util.e.b(var4, var2);
        } else {
            var6 = org.jeecg.modules.jmreport.desreport.util.e.a(var4, var2, var3);
        }

        HashMap var17 = new HashMap();

        try {
            JSONObject var18 = RegexMatches.e(var6);
            var9 = "";
            String var10 = "";
            String var11 = "";
            String var12 = "";
            String var13 = var1.getApiConvert();
            if (oConvertUtils.isEmpty(var13)) {
                if (var18.containsKey("data")) {
                    var9 = var18.get("data").toString();
                }

                if (var18.containsKey("links")) {
                    var10 = var18.get("links").toString();
                }

                if (var18.containsKey("total")) {
                    if (var18.get("total") != null) {
                        var11 = var18.get("total").toString();
                    } else {
                        var11 = "0";
                    }
                }

                if (var18.containsKey("count")) {
                    if (var18.get("count") != null) {
                        var12 = var18.get("count").toString();
                    } else {
                        var12 = "0";
                    }
                }
            } else {
                Object var14 = JimuSpringContextUtils.getBean(var13);
                if (var14 == null || !(var14 instanceof ApiDataConvertAdapter)) {
                    throw new JimuReportException("api转换器不识别，请确认!");
                }

                ApiDataConvertAdapter var15 = (ApiDataConvertAdapter)var14;
                var9 = var15.getData(var18);
                var10 = var15.getLinks(var18);
                var11 = var15.getTotal(var18);
                var12 = var15.getCount(var18);
            }

            List var19 = (List)JSONArray.parseObject(var9, List.class);
            List var20 = (List)JSONArray.parseObject(var10, List.class);
            var17.put("dataList", var19);
            var17.put("linkList", var20);
            var17.put("total", var11);
            var17.put("count", var12);
        } catch (Exception var16) {
            var16.printStackTrace();
        }

        return var17;
    }

    private String a(JmReportDb var1, Map<String, String[]> var2) {
        String var3 = var1.getDbDynSql().replace("\n", " ");
        boolean var4 = var3.contains("$");
        if (var4) {
            List var5 = this.dbParamDao.list(var1.getId());
            Iterator var6;
            JmReportDbParam var7;
            String var9;
            String var10;
            if (var2.size() > 0 && !var2.isEmpty()) {
                for(var6 = var2.keySet().iterator(); var6.hasNext(); var3 = var3.replace("${" + var10 + "}", var9)) {
                    var10 = (String)var6.next();
                    String[] var8 = (String[])var2.get(var10);
                    var9 = oConvertUtils.join(var8, (String)null, 0, var8.length);
                }
            } else {
                for(var6 = var5.iterator(); var6.hasNext(); var3 = var3.replace("${" + var7.getParamName() + "}", var7.getParamValue())) {
                    var7 = (JmReportDbParam)var6.next();
                }
            }
        }

        return var3;
    }

    private JSONObject a(JSONObject var1, Map<String, String> var2) {
        JSONObject var3 = new JSONObject(true);
        var2.forEach((var2x, var3x) -> {
            var3.put(var3x, var1.get(var2x));
        });
        var2.forEach((var1x, var2x) -> {
            var1.remove(var1x);
        });
        Iterator var4 = var3.keySet().iterator();

        while(var4.hasNext()) {
            String var5 = (String)var4.next();
            var1.put(var5, var3.get(var5));
        }

        return var1;
    }

    private JSONObject a(JSONObject var1) {
        ArrayList var2 = new ArrayList();
        Iterator var3 = var1.keySet().iterator();

        while(var3.hasNext()) {
            String var4 = (String)var3.next();
            if (oConvertUtils.isNotEmpty(var4) && !"NaN".equals(var4)) {
                var2.add(Integer.parseInt(var4));
            }
        }

        Collections.sort(var2);
        JSONArray var9 = new JSONArray();
        JSONObject var5 = new JSONObject(true);
        Iterator var6 = var2.iterator();

        while(var6.hasNext()) {
            Integer var7 = (Integer)var6.next();
            JSONObject var8 = var1.getJSONObject(String.valueOf(var7));
            var9.add(var8);
            var5.put(String.valueOf(var7), var8);
        }

        return var5;
    }

    public static Map<String, Object> a(Map<String, Object> var0) {
        HashMap var1 = new HashMap();
        if (var0 != null && !var0.isEmpty()) {
            Set var2 = var0.keySet();
            Iterator var3 = var2.iterator();

            while(var3.hasNext()) {
                String var4 = (String)var3.next();
                String var5 = var4.toLowerCase();
                var1.put(var5, var0.get(var4));
            }

            return var1;
        } else {
            return var1;
        }
    }

    public static boolean a(Row var0) {
        if (var0 == null) {
            return true;
        } else {
            for(int var1 = var0.getFirstCellNum(); var1 < var0.getLastCellNum(); ++var1) {
                Cell var2 = var0.getCell(var1);
                if (var2 != null && var2.getCellTypeEnum() != CellType.BLANK) {
                    return false;
                }
            }

            return true;
        }
    }

    public List<JmReportDbParam> queryReportParam(String reportId) {
        return this.reportDao.queryReportParam(reportId);
    }

    public List<QueryVO> getReportQueryInfo(String reportId, String params) {
        ArrayList var3 = null;
        List var4 = this.reportDbDao.selectList(reportId);
        String var5 = this.jimuTokenClient.getToken();
        Object var6 = new HashMap();
        if (oConvertUtils.isNotEmpty(var5)) {
            var6 = this.jimuTokenClient.getUserInfo(var5);
        }

        if (var4 != null && var4.size() > 0) {
            var3 = new ArrayList();
            HashSet var7 = new HashSet();
            ArrayList var8 = new ArrayList();
            HashSet var9 = new HashSet();
            Iterator var10 = var4.iterator();

            label99:
            while(true) {
                JmReportDb var11;
                String var12;
                String var13;
                String var18;
                String var20;
                String var22;
                String var25;
                List var29;
                do {
                    do {
                        if (!var10.hasNext()) {
                            if (var3.size() > 0) {
                                var10 = var3.iterator();

                                while(var10.hasNext()) {
                                    QueryVO var28 = (QueryVO)var10.next();
                                    if (var7.contains(var28.getName())) {
                                        var28.setDuplicate(true);
                                    }
                                }
                            }
                            break label99;
                        }

                        var11 = (JmReportDb)var10.next();
                        var12 = var11.getDbCode();
                        var13 = var11.getDbChName();
                        List var14 = this.dbFieldDao.listByDbId(var11.getId());
                        if (var14 != null && var14.size() > 0) {
                            Iterator var15 = var14.iterator();

                            while(var15.hasNext()) {
                                JmReportDbField var16 = (JmReportDbField)var15.next();
                                if (JmConst.FIELD_IS_QUERY.equals(var16.getSearchFlag())) {
                                    String var17 = var16.getFieldName();
                                    if (var8.contains(var17)) {
                                        var7.add(var17);
                                    }

                                    var8.add(var17);
                                    var18 = var16.getFieldText();
                                    Integer var19 = var16.getSearchMode();
                                    var20 = var16.getWidgetType();
                                    QueryVO var21 = new QueryVO(var17, var18, var20, var19, var12, var13);
                                    var22 = org.jeecg.modules.jmreport.desreport.express.b.a(var16.getSearchValue(), var19, (Map)var6);
                                    var21.setDefaultValue(var22);
                                    var21.setSort(var16.getOrderNum());
                                    var21.setFormat(var16.getSearchFormat());
                                    String var23 = org.jeecg.modules.jmreport.desreport.util.e.e(var20, var16.getSearchFormat());
                                    var21.setRealType(var23);
                                    List var24 = this.queryQueryDictList(var11, var16, (String)null, params);
                                    var21.setDictList(var24);
                                    var21.setDictCode(var16.getDictCode());
                                    var25 = var16.getExtJson();
                                    this.a(var21, var25);
                                    var3.add(var21);
                                }
                            }
                        }

                        var29 = this.dbParamDao.querySearchParam(var11.getId());
                    } while(var29 == null);
                } while(var29.size() <= 0);

                Iterator var30 = var29.iterator();

                while(true) {
                    JmReportDbParam var31;
                    do {
                        do {
                            if (!var30.hasNext()) {
                                continue label99;
                            }

                            var31 = (JmReportDbParam)var30.next();
                        } while(var31.getSearchFlag() != JmConst.FIELD_IS_QUERY);

                        var18 = var31.getParamName();
                    } while(var9.contains(var18));

                    var9.add(var18);
                    String var32 = var31.getParamTxt();
                    var20 = var31.getDictCode();
                    Integer var33 = var31.getSearchMode();
                    if (var33 == null) {
                        var33 = 1;
                    }

                    var22 = var31.getWidgetType();
                    if (var22 == null || "".equals(var22)) {
                        var22 = "String";
                    }

                    QueryVO var34 = new QueryVO(var18, var32, var22, var33, var12, var13);
                    String var35 = org.jeecg.modules.jmreport.desreport.express.b.a(var31.getParamValue(), var33, (Map)var6);
                    var34.setDefaultValue(var35);
                    var34.setParamSearch(true);
                    var34.setSort(var31.getOrderNum());
                    var34.setFormat(var31.getSearchFormat());
                    var25 = org.jeecg.modules.jmreport.desreport.util.e.e(var22, var31.getSearchFormat());
                    var34.setRealType(var25);
                    List var26 = this.queryDictListByCode(var20, var18, (String)null, var11.getDbSource());
                    var34.setDictList(var26);
                    var34.setDictCode(var31.getDictCode());
                    String var27 = var31.getExtJson();
                    this.a(var34, var27);
                    var3.add(var34);
                }
            }
        }

        if (var3 != null && var3.size() > 0) {
            Collections.sort(var3);
        }

        return var3;
    }

    private void a(QueryVO var1, String var2) {
        if (oConvertUtils.isNotEmpty(var2)) {
            JSONObject var3 = JSONObject.parseObject(var2);
            Object var4 = var3.get("loadTree");
            if (oConvertUtils.isNotEmpty(var4)) {
                String var5 = org.jeecg.modules.jmreport.desreport.util.e.a(var4.toString(), (Map)null, this.jmBaseConfig.getApiBasePath());
                var1.setLoadTree(var5);
            }
        }

    }

    public List<JmDictModel> queryDictListByCode(String dictCode, String fieldName, String text, String dbSource) {
        List var5 = null;
        if (dictCode != null && !"".equals(dictCode)) {
            Map var6 = this.jimuTokenClient.getUserInfo(this.jimuTokenClient.getToken());
            dictCode = org.jeecg.modules.jmreport.desreport.util.e.a(dictCode, var6, this.jmBaseConfig.getApiBasePath());
            if (dictCode.contains("http")) {
                var5 = this.a(dictCode, fieldName);
            } else if (dictCode.toLowerCase().indexOf("select") >= 0 && dictCode.toLowerCase().indexOf("from") >= 0) {
                dictCode = "SELECT distinct dict.text,dict.value FROM (" + dictCode + ") dict";
                if (oConvertUtils.isNotEmpty(text)) {
                    dictCode = dictCode + " WHERE dict.value like '%" + text + "%'";
                }

                if (oConvertUtils.isNotEmpty(dbSource)) {
                    List var7 = this.jmreportDynamicDbUtil.findList(dbSource, dictCode, new Object[0]);
                    var5 = this.a(var7);
                } else {
                    MiniDaoPage var8 = this.reportDao.queryDictBySqlPage(dictCode, 1, 10);
                    var5 = var8.getResults();
                }
            } else {
                var5 = this.dictService.queryDictItemsByCode(dictCode);
            }
        }

        return var5;
    }

    public List<JmDictModel> queryQueryDictList(JmReportDb db, JmReportDbField temp, String text, String params) {
        String var5 = temp.getDictCode();
        String var6 = temp.getWidgetType();
        List var7 = null;
        Integer var8 = temp.getSearchMode();
        if (var5 != null && !"".equals(var5)) {
            var7 = this.queryDictListByCode(var5, temp.getFieldName(), text, db.getDbSource());
        } else if (var8 != null && (var8 == 3 || var8 == 4)) {
            Object var9 = new ArrayList();
            String var10 = db.getDbDynSql();
            if (oConvertUtils.isNotEmpty(var10)) {
                JSONObject var11 = new JSONObject();
                if (oConvertUtils.isNotEmpty(params)) {
                    var11 = JSONObject.parseObject(params);
                }

                Iterator var12 = var11.keySet().iterator();

                while(var12.hasNext()) {
                    String var13 = (String)var12.next();
                    String var14 = "${" + var13 + "}";
                    if (var10.contains(var13)) {
                        Object var15 = var11.get(var13);
                        var10 = var10.replace(var14, var15.toString());
                        var10 = var10.replace("'${" + var13 + "}'", var15.toString());
                    }
                }

                Map var17 = this.jimuTokenClient.getUserInfo(this.jimuTokenClient.getToken());
                var10 = org.jeecg.modules.jmreport.desreport.util.e.b(var10, var17);
                var10 = FreeMarkerUtils.a(var10, new HashMap());
                var10 = org.jeecg.modules.jmreport.desreport.util.e.a(var10, "\\$");
                var10 = "SELECT distinct dict." + temp.getFieldName() + " FROM (" + var10 + ") dict ";
                if (oConvertUtils.isNotEmpty(text)) {
                    var10 = var10 + " WHERE dict." + temp.getFieldName() + " like '%" + text + "%'";
                }

                if (oConvertUtils.isNotEmpty(db.getDbSource())) {
                    try {
                        JmreportDynamicDataSourceVo var18 = JmreportDataSourceCachePool.getCacheDynamicDataSourceModel(db.getDbSource());
                        var10 = MiniDaoUtil.createPageSql(var18.getDbUrl(), var10, 1, this.jmBaseConfig.selectShowTotal);
                        var9 = this.jmreportDynamicDbUtil.findList(db.getDbSource(), var10, new Object[0]);
                    } catch (Exception var16) {
                        a.warn(var16.getMessage(), var16);
                    }
                } else {
                    MiniDaoPage var19 = this.reportDbDao.selectPageBySql(var10, 1, this.jmBaseConfig.selectShowTotal);
                    var9 = var19.getResults();
                }

                var7 = this.a((JmReportDbField)temp, (List)var9);
                if (null != var7 && ("date".equals(var6) || "datetime".equals(var6))) {
                    this.d(var7);
                }
            }
        }

        return var7;
    }

    private void d(List<JmDictModel> var1) {
        Iterator var2 = var1.iterator();

        while(var2.hasNext()) {
            JmDictModel var3 = (JmDictModel)var2.next();
            int var4 = var3.getValue().length();
            if (var4 > 19) {
                String var5 = var3.getValue();
                var3.setValue(var5.substring(0, 19));
                var3.setText(var5.substring(0, 19));
            }
        }

    }

    public List<JmDictModel> getDictListByCode(JmReportDbField dbField, String dbSource) {
        String var3 = dbField.getDictCode();
        List var4 = null;
        if (var3.toLowerCase().indexOf("select") >= 0 && var3.toLowerCase().indexOf("from") >= 0) {
            if (oConvertUtils.isNotEmpty(dbSource)) {
                List var5 = this.jmreportDynamicDbUtil.findList(dbSource, var3, new Object[0]);
                var4 = this.a(var5);
            } else {
                var4 = this.reportDao.queryDictBySql(var3);
            }
        } else {
            var4 = this.dictService.queryDictItemsByCode(var3);
        }

        return var4;
    }

    public JSONObject addChart(String chartType) {
        JSONObject var2 = null;

        try {
            String var3 = "static/jmreport/desreport_/chartjson/" + chartType + ".json";
            ClassPathResource var4 = new ClassPathResource(var3);
            byte[] var5 = FileCopyUtils.copyToByteArray(var4.getInputStream());
            String var6 = new String(var5, "UTF-8");
            var2 = JSON.parseObject(var6);
        } catch (IOException var7) {
            var7.printStackTrace();
        }

        return var2;
    }

    public JimuReport excelCreate(JimuReport design) {
        Date var2 = new Date();
        design.setDelFlag(CommonConstant.DEL_FLAG_0);
        design.setUpdateTime(var2);
        if (oConvertUtils.isNotEmpty(design.getId())) {
            design.setUpdateBy(design.getCreateBy());
            this.reportDao.update(design);
        } else {
            design.setCreateTime(var2);
            this.reportDao.insert(design);
        }

        return design;
    }

    public Result<JimuReport> show(String id, String params, String dbCode) {
        JSONObject var4 = new JSONObject();
        boolean var5 = false;
        if (oConvertUtils.isNotEmpty(params)) {
            var4 = JSON.parseObject(params);
            var5 = "1".equals(var4.getString("onlyPageData"));
        }

        a.debug("============EXCEL JSON数据查询==========");
        JimuReport var6 = this.reportDao.get(id);
        String var7 = var6.getJsonStr();
        this.a(var4, var7);
        Map var8 = this.getDataById(var6, var4, var5, dbCode);
        this.a(var7, var8);
        var6.setDataList(var8);
        a.debug("====配置的json字符串===" + var6.getJsonStr());
        var7 = ReportUtil.a(var8, var7);
        JSONObject var9 = (JSONObject)var8.get("replaceParams");
        var7 = ReportUtil.a(var7, var9);
        var6.setJsonStr(var7);
        RenderInfo var10 = new RenderInfo(var6);
        var10.setStrategyName(b.class.getSimpleName());
        Result var11 = this.a(var10);
        org.jeecg.modules.jmreport.desreport.express.b.a(var11);
        return var11;
    }

    private void a(JSONObject var1, String var2) {
        if (var1.containsKey("jmViewFirstLoad") && "1".equals(var1.getString("jmViewFirstLoad"))) {
            JSONObject var3 = JSONObject.parseObject(var2);
            if (var3.containsKey("rpbar")) {
                JSONObject var4 = var3.getJSONObject("rpbar");
                if (var4.containsKey("pageSize")) {
                    Integer var5 = var4.getInteger("pageSize");
                    if (var5 != null && !"".equals(var5)) {
                        var1.put("pageSize", var5);
                    }
                }
            }
        }

    }

    private void a(String var1, Map<String, Object> var2) {
        JSONObject var3 = JSON.parseObject(var1);
        if (var3.containsKey("completeBlankRowList")) {
            JSONArray var4 = var3.getJSONArray("completeBlankRowList");
            if (var4.size() > 0) {
                Iterator var5 = var2.keySet().iterator();

                while(true) {
                    Object var11;
                    int var12;
                    JSONObject var13;
                    Integer var17;
                    int var19;
                    do {
                        Object var18;
                        do {
                            String var6;
                            do {
                                do {
                                    JSONObject var7;
                                    do {
                                        if (!var5.hasNext()) {
                                            return;
                                        }

                                        var6 = (String)var5.next();
                                        var7 = null;

                                        for(int var8 = 0; var8 < var4.size(); ++var8) {
                                            JSONObject var9 = var4.getJSONObject(var8);
                                            if (var9.getString("db").equals(var6)) {
                                                var7 = var9;
                                                break;
                                            }
                                        }
                                    } while(var7 == null);

                                    var17 = var7.getInteger("rows");
                                } while(var17 == null);
                            } while(var17 <= 0);

                            var18 = var2.get(var6);
                        } while(!(var18 instanceof ReportDbInfo));

                        ReportDbInfo var10 = (ReportDbInfo)var18;
                        var11 = var10.getList();
                        var12 = ((List)var11).size();
                        var13 = new JSONObject();
                        if (var11 == null) {
                            var11 = new ArrayList();
                        } else if (var12 != 0) {
                            Map var14 = (Map)((List)var11).get(0);
                            Iterator var15 = var14.keySet().iterator();

                            while(var15.hasNext()) {
                                String var16 = (String)var15.next();
                                var13.put(var16, "");
                            }
                        }

                        var19 = var12 % var17;
                    } while(var19 <= 0 && var12 != 0);

                    for(int var20 = var17 - var19; var20 > 0; --var20) {
                        ((List)var11).add(var13);
                    }
                }
            }
        }

    }

    private Result<JimuReport> a(RenderInfo var1) {
        if (oConvertUtils.isNotEmpty(this.renderHandlerMap)) {
            Iterator var2 = this.renderHandlerMap.values().iterator();

            while(var2.hasNext()) {
                BaseRenderHandler var3 = (BaseRenderHandler)var2.next();
                if (var3.support(var1)) {
                    JimuReport var4 = var1.getReport();
                    JSONObject var5 = JSONObject.parseObject(var4.getJsonStr(), new Feature[]{Feature.OrderedField});
                    JSONArray var6 = this.a(var1, var5, var4);
                    var3.beforeRender(var1);
                    Result var7 = var3.render(var1);
                    this.a(var6, var7, var3, var1, var5, var4);
                    if (oConvertUtils.isNotEmpty(var7)) {
                        return var7;
                    }

                    Result.OK(var1.getReport());
                }
            }
        }

        return Result.OK(var1.getReport());
    }

    private JSONArray a(RenderInfo var1, JSONObject var2, JimuReport var3) {
        JSONArray var4 = var2.getJSONArray("zonedEditionList");
        if (oConvertUtils.isNotEmpty(var4)) {
            JSONObject var5 = var2.getJSONObject("rows");

            JSONObject var8;
            JSONObject var9;
            for(Iterator var6 = var4.iterator(); var6.hasNext(); var9.put("jsons", JSONUtils.toJSONString(var8))) {
                Object var7 = var6.next();
                var8 = new JSONObject(true);
                var9 = (JSONObject)var7;
                Integer var10 = var9.getInteger("sri");
                Integer var11 = var9.getInteger("eri");
                Integer var12 = var9.getInteger("sci");
                Integer var13 = var9.getInteger("eci");
                if (var10 >= 0) {
                    for(int var14 = var10; var14 <= var11; ++var14) {
                        JSONObject var15 = var5.getJSONObject(var14 + "");
                        if (oConvertUtils.isNotEmpty(var15)) {
                            JSONObject var16 = new JSONObject(true);

                            for(int var17 = var12; var17 <= var13; ++var17) {
                                JSONObject var18 = var15.getJSONObject("cells");
                                if (oConvertUtils.isNotEmpty(var18)) {
                                    JSONObject var19 = var18.getJSONObject(var17 + "");
                                    var16.put(var17 + "", var19);
                                    var18.remove(var17 + "");
                                }
                            }

                            JSONObject var20 = new JSONObject(true);
                            var20.put("cells", var16);
                            var8.put(var14 + "", var20);
                        }
                    }
                }
            }

            var2.put("rows", var5);
            var3.setJsonStr(JSONUtils.toJSONString(var2));
            var1.setReport(var3);
        }

        var1.setZonedEditionList(var4);
        return var4;
    }

    private void a(JSONArray var1, Result<JimuReport> var2, BaseRenderHandler var3, RenderInfo var4, JSONObject var5, JimuReport var6) {
        if (oConvertUtils.isNotEmpty(var1)) {
            String var7 = ((JimuReport)var2.getResult()).getJsonStr();
            JSONObject var8 = JSONObject.parseObject(var7, new Feature[]{Feature.OrderedField});
            JSONObject var9 = var8.getJSONObject("rows");
            Iterator var10 = var1.iterator();

            while(true) {
                JSONObject var21;
                do {
                    if (!var10.hasNext()) {
                        return;
                    }

                    Object var11 = var10.next();
                    JSONObject var12 = (JSONObject)var11;
                    String var13 = var12.getString("jsons");
                    Integer var14 = var12.getInteger("sri");
                    Integer var15 = var12.getInteger("eri");
                    JimuReport var16 = new JimuReport();
                    BeanUtils.copyProperties(var6, var16);
                    JSONObject var17 = JSONObject.parseObject(var16.getJsonStr(), new Feature[]{Feature.OrderedField});
                    var17.put("rows", var13);
                    var16.setJsonStr(var17.toString());
                    var4.setReport(var16);
                    var3.beforeRender(var4);
                    Result var18 = var3.render(var4);
                    String var19 = ((JimuReport)var18.getResult()).getJsonStr();
                    JSONObject var20 = JSONObject.parseObject(var19, new Feature[]{Feature.OrderedField});
                    var21 = var20.getJSONObject("rows");
                } while(!oConvertUtils.isNotEmpty(var21));

                Iterator var22 = var21.entrySet().iterator();

                while(var22.hasNext()) {
                    Entry var23 = (Entry)var22.next();
                    String var24 = var23.getKey().toString();
                    Object var25 = var23.getValue();
                    if (var25 instanceof JSONObject) {
                        JSONObject var26 = (JSONObject)var25;
                        JSONObject var27 = var26.getJSONObject("cells");
                        JSONObject var28 = var9.getJSONObject(var24);
                        if (oConvertUtils.isNotEmpty(var28)) {
                            var28.getJSONObject("cells").putAll(var27);
                        } else {
                            var9.put(var24, var25);
                        }
                    }
                }

                var5.put("rows", var9);
                var6.setJsonStr(JSONUtils.toJSONString(var5));
                var4.setReport(var6);
            }
        }
    }

    public JimuReport saveReport(JSONObject json, HttpServletRequest request) {
        String var3 = this.jimuTokenClient.getUsername(request);
        a.debug("============EXCEL JSON数据正在保存==========");
        String var4 = json.getString("excel_config_id");
        JimuReport var5 = new JimuReport();
        if (oConvertUtils.isEmpty(var4)) {
            var5.setId(String.valueOf(SnowflakeIdWorker.generateId()));
            var5.setIsRefresh(false);
            return var5;
        } else {
            var5 = this.reportDao.get(var4);
            JSONObject var6 = json.getJSONObject("designerObj");
            String var7 = "";
            String var8 = "";
            if (var6 != null) {
                var7 = var6.getString("name");
                var8 = var6.getString("type");
                json.remove("designerObj");
            }

            SimpleDateFormat var9 = new SimpleDateFormat("yyyyMMddHHmmss");
            String var10 = var9.format(new Date());
            if (var5 == null) {
                JimuReport var11 = new JimuReport();
                var11.setId(var4);
                var11.setCode(var10);
                var11.setViewCount(0L);
                var11.setDelFlag(CommonConstant.DEL_FLAG_0);
                var11.setTemplate(JmConst.TEMPLATE_FLAG_0);
                var11.setJsonStr(json.toJSONString());
                var11.setName(var7);
                var11.setType(var8);
                var11.setCreateBy(var3);
                Date var12 = new Date();
                var11.setCreateTime(var12);
                var11.setUpdateTime(var12);
                json.remove("excel_config_id");
                this.reportDao.insert(var11);
                var5 = new JimuReport();
                var5.setIsRefresh(true);
            } else {
                var5.setName(var7);
                var5.setType(var8);
                var5.setUpdateBy(var3);
                var5.setUpdateTime(new Date());
                var5.setJsonStr(json.toJSONString());
                a.info("保存设计，saas: " + this.jmBaseConfig.getSaas() + " ,登录Token: " + this.jimuTokenClient.getToken());
                if (this.jmBaseConfig.getSaas() && oConvertUtils.isNotEmpty(this.jimuTokenClient.getToken())) {
                    String var13 = this.jimuTokenClient.getUsername(request);
                    if (!var5.getCreateBy().equals(var13)) {
                        throw new JimuReportException("保存失败！");
                    }

                    this.reportDao.update(var5);
                } else {
                    this.reportDao.update(var5);
                }

                var5.setIsRefresh(false);
            }

            return var5;
        }
    }

    public void replaceDbCode(JmReportDb reportDb, List<Map<String, Object>> dataList) {
        String var3 = reportDb.getId();
        if (oConvertUtils.isNotEmpty(var3)) {
            List var4 = this.dbFieldDao.listByDbIdNotNull(var3);
            Iterator var5 = var4.iterator();

            while(var5.hasNext()) {
                JmReportDbField var6 = (JmReportDbField)var5.next();
                List var7 = null;
                Map var8 = this.jimuTokenClient.getUserInfo(this.jimuTokenClient.getToken());
                String var9 = org.jeecg.modules.jmreport.desreport.util.e.a(var6.getDictCode(), var8, this.jmBaseConfig.getApiBasePath());
                if (var9.contains("http")) {
                    var6.setDictCode(var9);
                    var7 = this.a(var6);
                } else {
                    var7 = this.getDictListByCode(var6, reportDb.getDbSource());
                }

                Iterator var10 = dataList.iterator();

                while(var10.hasNext()) {
                    Map var11 = (Map)var10.next();
                    Object var12 = var11.get(var6.getFieldName());
                    String var13 = var12 == null ? null : var12.toString();
                    Object var14 = new ArrayList();
                    //if (oConvertUtils.isNotEmpty(var13) && null != var7) {
                    //    var14 = (List)var7.stream().filter((var1) -> {
                    //        return var13.equals(var1.getValue());
                    //    }).collect(Collectors.toList());
                    //}

                    if (((List)var14).size() > 0) {
                        var11.replace(var6.getFieldName(), ((JmDictModel)((List)var14).get(0)).getText());
                    }
                }
            }
        }

    }

    public List<JimuReport> getReportByUser(String username, String reportId) {
        return this.reportDao.getReportByUser(username, reportId);
    }

    public JSONObject getCharData(String reportId, String charId, String params, String token) {
        JSONObject var5 = new JSONObject();
        JimuReport var6 = this.reportDao.get(reportId);
        String var7 = var6.getJsonStr();
        JSONObject var8 = JSONObject.parseObject(var7);
        Object var9 = var8.get("chartList");
        JSONObject var10 = new JSONObject();
        if (null != var9) {
            JSONArray var11 = JSONArray.parseArray(var9.toString());

            for(int var12 = 0; var12 < var11.size(); ++var12) {
                Object var13 = var11.getJSONObject(var12).get("layer_id");
                if (null != var13 && charId.equals(var13.toString())) {
                    var10 = var11.getJSONObject(var12);
                }
            }
        }

        if (null != var10) {
            Object var16 = var10.get("config");
            Object var17 = var10.get("extData");
            var5.put("config", var16);
            var5.put("extData", var17);
            if (null != var17) {
                JSONObject var18 = JSONObject.parseObject(var17.toString());
                String var14 = String.valueOf(var18.get("dbCode"));
                String var15 = this.a(reportId, var14, params, token);
                var5.put("dataList", var15);
                return var5;
            }
        }

        return null;
    }

    public JimuReport getById(String id) {
        return this.reportDao.get(id);
    }

    public Integer updateById(JimuReport rp) {
        return this.reportDao.update(rp);
    }

    public int updateViewCount(String id) {
        return this.reportDao.updateViewCount(id);
    }

    private String a(String var1, String var2, String var3, String var4) {
        JmReportDb var5 = this.reportDbDao.getReportDb(var1, var2);
        JSONArray var6 = JSONArray.parseArray(var3);
        HashMap var7 = new HashMap();
        JSONObject var8 = new JSONObject();
        Iterator var9 = var6.iterator();

        while(true) {
            Object var10;
            do {
                if (!var9.hasNext()) {
                    if (var5.getDbType().equals("0")) {
                        String var17 = this.getBaseSql(var5, var8);
                        if (oConvertUtils.isNotEmpty(var5.getDbSource())) {
                            var10 = new ArrayList();

                            try {
                                var10 = this.jmreportDynamicDbUtil.findList(var5.getDbSource(), var17, new Object[0]);
                            } catch (Exception var15) {
                                a.warn(var15.getMessage(), var15);
                            }

                            return this.b((List)var10);
                        }

                        List var20 = this.reportDbDao.selectListBySql(var17);
                        return this.b(var20);
                    }

                    JSONObject var16 = new JSONObject();
                    String var18 = var5.getApiUrl();
                    var18 = FreeMarkerUtils.a(var18, var7);
                    var18 = var18.replace("'", "");
                    var5.setApiUrl(var18);
                    Map var19 = this.a(var5, var4, var16);
                    Object var21 = var19.get("dataList");
                    if (oConvertUtils.isNotEmpty(var21)) {
                        return String.valueOf(var21);
                    }

                    return null;
                }

                var10 = var9.next();
            } while(!(var10 instanceof JSONObject));

            JSONObject var11 = JSONObject.parseObject(var10.toString());
            Iterator var12 = var11.keySet().iterator();

            while(var12.hasNext()) {
                String var13 = (String)var12.next();
                String var14 = var11.getString(var13);
                var7.put(var13, var14);
                var8.put(var13, var14);
            }
        }
    }
    //遍历求出group by
    private void a(JmReportDb var1, String var2, String var3, List<JmExpression> var4) {
        Iterator var5 = var4.iterator();

        while(var5.hasNext()) {
            JmExpression var6 = (JmExpression)var5.next();
            if (var1.getDbCode().equals(var6.getDbCode())) {
                String var7 = var6.getFullSql(var2, var3);
                a.info("---表达式sql:" + var7);
                if (oConvertUtils.isEmpty(var1.getDbSource())) {
                    JmExpBacker var8 = this.reportDao.queryExpValue(var7);
                    var6.setValue(var8 == null ? "" : var8.getAskey());
                } else {
                    Object var11 = new HashMap();

                    try {
                        var11 = (Map)this.jmreportDynamicDbUtil.findOne(var1.getDbSource(), var7, new Object[0]);
                    } catch (Exception var10) {
                        a.warn(var10.getMessage(), var10);
                    }

                    var6.setValue(((Map)var11).get("askey") == null ? "" : ((Map)var11).get("askey").toString());
                }
            }
        }

    }
    //外面在封装一层 select from ( sql)
    private String a(String var1, String var2, String var3) {
        if (var2 != null && !"".equals(var2)) {
            var1 = "select * from (" + var1 + ") jeecg_rp_temp  where 1=1 " + var2;
        }

        if (oConvertUtils.isNotEmpty(var3)) {
            String var4 = "order by";
            if (!var1.contains(var4)) {
                var1 = var1 + " " + var4 + " " + var3;
            } else {
                String var5 = var1.substring(var1.indexOf(var4) + var4.length());
                var5 = var5 + "," + var3;
                var1 = var1.substring(0, var1.indexOf(" " + var4 + " ")) + " " + var4 + " " + var5;
            }
        }

        return var1;
    }

    //参数条件
    private String a(JmReportDb var1, JSONObject var2) {
        String var3 = var1.getDbCode();
        String var4 = var1.getDbSourceType();
        if (oConvertUtils.isNotEmpty(var1.getDbSource())) {
            JmReportDataSource var5 = this.jimuReportDataSourceDao.get(var1.getDbSource());
            if (var5 != null) {
                var4 = MiniDaoUtil.getDbType(var5.getDbUrl());
            }
        }

        List var10 = this.dbFieldDao.listByDbIdFlag(var1.getId());
        String var6 = null;
        if (var10 != null && var10.size() > 0) {
            StringBuffer var7 = new StringBuffer();
            Iterator var8 = var10.iterator();

            while(var8.hasNext()) {
                JmReportDbField var9 = (JmReportDbField)var8.next();
                org.jeecg.modules.jmreport.desreport.util.e.a(var3, var4, var9, var2, var7);
            }

            var6 = var7.toString();
        }

        return var6;
    }

    public String getBaseSql(JmReportDb jmReportDb, JSONObject paramJson) {
        String var3 = jmReportDb.getId();
        String var4 = jmReportDb.getDbCode();
        String var5 = jmReportDb.getDbDynSql();
        new HashMap();
        JSONObject var7 = new JSONObject();
        String var11;
        if (var5.contains("where")) {
            List var8 = this.dbParamDao.list(var3);
            if (var8 != null || var8.size() > 0) {
                Iterator var9 = var8.iterator();

                while(var9.hasNext()) {
                    JmReportDbParam var10 = (JmReportDbParam)var9.next();
                    var11 = var10.getParamName();
                    if (var10.getSearchFlag() == 1) {
                        Object var12 = paramJson.get(var10.getParamName());
                        if (var12 == null) {
                            var12 = "";
                        }

                        var7.put(var11, var12);
                        paramJson.remove(var11);
                    } else {
                        var7.put(var11, var10.getParamValue());
                    }
                }
            }
        }

        var7.putAll(paramJson);
        String var13 = this.jimuTokenClient.getToken();
        if (var13 != null && var13.length() > 0) {
            Map var14 = this.jimuTokenClient.getUserInfo(var13);
            var5 = org.jeecg.modules.jmreport.desreport.util.e.b(var5, var14);  //是否有#{} 变量的

            //多租户处理
            var5=tenantSql(var5,var14);
        }

        HashMap var15 = new HashMap();
        Iterator var16 = var7.keySet().iterator();

        while(var16.hasNext()) {
            var11 = (String)var16.next();
            String var17 = var7.getString(var11);
            if (oConvertUtils.isEmpty(var17)) {
                var17 = "";
            }

            var17 = org.jeecg.modules.jmreport.desreport.express.b.a(var17, (Map)null);
            var15.put(var11, var17);
        }

        var5 = FreeMarkerUtils.a(var5, var15);
        return var5;
    }

    //多租户处理
    /**
     select
     from mws_t_chg_fees t1  --必须有别名加空格
     where t1.del_falg=0  and .... --存在from 的租户必须 是from 别名开头

     * */
    public String tenantSql(String baseSql,Map userMap){
        //多租户处理
        StringBuffer sb=new StringBuffer();

        String mainNickSql="";
        int useIndex=0;
        JSONObject sqlWhereObj = new JSONObject();


        String[] bsSql = baseSql.split("\n");
        for (int i = 0; i < bsSql.length; i++) {
            boolean isFrom=false;
            boolean isJoin=false;
            int beginIndex=-1;

            String rowSql=bsSql[i];
            String currSql=rowSql.toLowerCase();

            if(currSql.contains("from ")){
                isFrom=true;
                beginIndex=currSql.indexOf("from ")+5;
            }else if(currSql.contains("inner join ")){
                isJoin=true;
                beginIndex=currSql.indexOf("inner join ")+11;
            }else if(currSql.contains("left join ")){
                isJoin=true;
                beginIndex=currSql.indexOf("left join ")+10;
            }
            if(isFrom){
                int endIndex = currSql.indexOf(" ", beginIndex);
                if(endIndex>0){
                    String ctable=currSql.substring(beginIndex,endIndex);
                    if(!mybatisPlusSaasConfig.ignoreTable(ctable)){
                        //是租户表
                        int index=beginIndex+ctable.length()+1;
                        String nick=currSql.substring(index,currSql.indexOf(" ",index));
                        mainNickSql=" and "+nick+".tenant_id="+userMap.get("tenant_id");
                        sqlWhereObj.put(nick,mainNickSql);
                    }
                }
            }
            if(isJoin){
                int endIndex = currSql.indexOf(" ", beginIndex);
                if(endIndex>0){
                    String ctable=currSql.substring(beginIndex,endIndex);
                    if(!mybatisPlusSaasConfig.ignoreTable(ctable)){
                        //是租户表
                        int index=beginIndex+ctable.length()+1;
                        String nick=currSql.substring(index,currSql.indexOf(" ",index));
                        rowSql=rowSql+" and "+nick+".tenant_id="+userMap.get("tenant_id");
                    }
                }
            }
            if( currSql.trim().contains("where") && currSql.trim().indexOf("where ")<7){
                int p=currSql.indexOf("where ")+6;
                String nickKey = currSql.substring(p, currSql.indexOf(".",p));
                String whereSqlKey = sqlWhereObj.getString(nickKey);
                if(null != whereSqlKey && whereSqlKey.length()>0){
                    rowSql=rowSql+whereSqlKey;
                }
            }
            sb.append(rowSql+"\n");
        }
        return sb.toString();
    }

    //报表列表
    public Result<JmPage<JimuReport>> excelQuery(String type, String name, HttpServletRequest request, Integer pageNo, Integer pageSize) {
        String var6 = this.jimuTokenClient.getUsername(request);
        JimuReport var7 = new JimuReport();
        if (oConvertUtils.isNotEmpty(var6) && this.jmBaseConfig.getSaas()) {
            var7.setCreateBy(var6);
        }

        if (oConvertUtils.isNotEmpty(type)) {
            var7.setType(type);
        }

        if (oConvertUtils.isNotEmpty(name)) {
            var7.setName("%" + name + "%");
        }

        var7.setDelFlag(CommonConstant.DEL_FLAG_0);
        var7.setTemplate(JmConst.TEMPLATE_FLAG_0);
        MiniDaoPage var8 = this.reportDao.pageList(var7, pageNo, pageSize);
        JmPage var9 = org.jeecg.modules.jmreport.desreport.util.d.a(var8);
        return Result.OK(var9);
    }

    public Result<JmPage<JimuReport>> excelQueryByTemplate(String type, String name, HttpServletRequest request, Integer pageNo, Integer pageSize) {
        JimuReport var6 = new JimuReport();
        if (oConvertUtils.isNotEmpty(type)) {
            var6.setType(type);
        }

        if (oConvertUtils.isNotEmpty(name)) {
            var6.setName("%" + name + "%");
        }

        var6.setDelFlag(CommonConstant.DEL_FLAG_0);
        var6.setTemplate(JmConst.TEMPLATE_FLAG_1);
        MiniDaoPage var7 = this.reportDao.pageList(var6, pageNo, pageSize);
        JmPage var8 = org.jeecg.modules.jmreport.desreport.util.d.a(var7);
        return Result.OK(var8);
    }

    public List<JmDictModel> a(JmReportDbField var1) {
        return this.a(var1.getDictCode(), var1.getFieldName());
    }

    public List<JmDictModel> a(String var1, String var2) {
        String var3 = this.jimuTokenClient.getToken();
        Map var4 = this.jimuTokenClient.getUserInfo(var3);
        var1 = org.jeecg.modules.jmreport.desreport.util.e.a(var1, var4, this.jmBaseConfig.getApiBasePath());
        if (var1.contains("'")) {
            var1 = var1.replace("'", "");
        }

        if (var2 != null && !"".equals(var2)) {
            if (var1.contains("?")) {
                var1 = var1 + "&" + "dictCode" + "=" + var2;
            } else {
                var1 = var1 + "?" + "dictCode" + "=" + var2;
            }
        }

        String var5 = org.jeecg.modules.jmreport.desreport.util.e.b(var1, (String)null);

        try {
            JSONArray var6 = JSONObject.parseArray(var5);
            ArrayList var7 = new ArrayList();

            for(int var8 = 0; var8 < var6.size(); ++var8) {
                JSONObject var9 = var6.getJSONObject(var8);
                Object var10 = var9.get("text");
                Object var11 = var9.get("value");
                if (oConvertUtils.isEmpty(var10) || oConvertUtils.isEmpty(var11)) {
                    return null;
                }

                JmDictModel var12 = new JmDictModel();
                var12.setText(var10.toString());
                var12.setValue(var11.toString());
                var7.add(var12);
            }

            return var7;
        } catch (Exception var13) {
            a.info("获取数据失败，原因：" + var13.getMessage());
            return null;
        }
    }

    public List<JmDictModel> a(JmReportDbField var1, List<Map<String, Object>> var2) {
        Integer var3 = var1.getSearchFlag();
        Integer var4 = var1.getSearchMode();
        String var5 = var1.getFieldName();
        if (var3 == CommonConstant.SEARCH_FLAG_1 && var4 != CommonConstant.SEARCH_MODEL_2) {
            ArrayList var6 = new ArrayList();
            Iterator var7 = var2.iterator();

            while(var7.hasNext()) {
                Map var8 = (Map)var7.next();
                Iterator var9 = var8.keySet().iterator();

                while(var9.hasNext()) {
                    String var10 = (String)var9.next();
                    if (var10.toLowerCase().equals(var5)) {
                        String var11 = String.valueOf(var8.get(var10));
                        if (oConvertUtils.isNotEmpty(var11)) {
                            JmDictModel var12 = new JmDictModel();
                            var12.setText(var11);
                            var12.setValue(var11);
                            var6.add(var12);
                        }
                    }
                }
            }

            return var6;
        } else {
            return null;
        }
    }

    public List<JmDictModel> a(List<Map<String, Object>> var1) {
        ArrayList var2 = new ArrayList();
        Iterator var3 = var1.iterator();

        while(var3.hasNext()) {
            Map var4 = (Map)var3.next();
            JmDictModel var5 = new JmDictModel();
            Object var6 = var4.get("text");
            Object var7 = var4.get("value");
            if (oConvertUtils.isNotEmpty(var6) && oConvertUtils.isNotEmpty(var7)) {
                var5.setText(var6.toString());
                var5.setValue(var7.toString());
                var2.add(var5);
            }
        }

        return var2;
    }

    public String b(List<Map<String, Object>> var1) {
        ArrayList var2 = new ArrayList();
        Iterator var3 = var1.iterator();

        while(var3.hasNext()) {
            Map var4 = (Map)var3.next();
            String var5 = JSONObject.toJSONString(var4);
            var2.add(var5.toLowerCase());
        }

        if (var2.size() > 0) {
            String var6 = var2.toString();
            return var6;
        } else {
            return null;
        }
    }

    private ReportDbInfo a(JmReportDb var1, JSONObject var2, List<Map<String, Object>> var3) {
        ReportDbInfo var4 = new ReportDbInfo(var1.getIsPage(), var1.getIsList(), var1.getDbType());
        String var5 = var1.getDbCode();
        HashMap var6 = new HashMap();
        List var7 = this.dbParamDao.list(var1.getId());
        ArrayList var8 = new ArrayList();
        var8.add("pageNo");
        var8.add("pageSize");
        var8.add("printAll");
        Iterator var9;
        String var11;
        if (org.jeecg.modules.jmreport.desreport.util.e.a(var7)) {
            var9 = var7.iterator();

            while(var9.hasNext()) {
                JmReportDbParam var10 = (JmReportDbParam)var9.next();
                var8.add(var10.getParamName());
                var11 = var10.getParamValue();
                if (var11 != null && !"".equals(var11)) {
                    var6.put(var10.getParamName(), var11);
                }
            }
        }

        var9 = var2.keySet().iterator();

        String var14;
        while(var9.hasNext()) {
            var14 = (String)var9.next();
            Object var15 = var2.get(var14);
            if (var15 != null) {
                if (var14.startsWith(var5)) {
                    var14 = var14.replace(var5 + "__", "");
                    var6.put(var14, var15);
                } else if (var8.indexOf(var14) >= 0) {
                    var6.put(var14, var15);
                }
            }
        }

        var14 = var1.getJavaType();
        var11 = var1.getJavaValue();
        IDataSetFactory var12 = org.jeecg.modules.jmreport.desreport.util.e.d(var14, var11);
        if (var12 == null) {
            return var4;
        } else {
            List var16;
            if ("1".equals(var1.getIsPage())) {
                JmPage var13 = var12.createPageData(var6);
                var4.setList(var13.getRecords());
                var4.setTotal((long)var13.getTotal());
            } else {
                var16 = var12.createData(var6);
                var4.setList(var16);
            }

            var3 = oConvertUtils.deepCopy(var4.getList());
            if (null != var4.getList()) {
                var16 = var4.getList();
                this.replaceDbCode(var1, var16);
                var4.setList(var16);
            }

            return var4;
        }
    }

    private String b(String var1, String var2, String var3) {
        if (oConvertUtils.isNotEmpty(var2)) {
            if (var1.contains("?")) {
                var1 = var1 + "&" + var3;
            } else {
                var1 = var1 + "?" + var3;
            }
        }

        return var1;
    }

    private JSONObject a(JmReportDb var1, Map<String, JSONObject> var2, String var3, String var4) {
        String var5 = var1.getDbCode();
        String var6 = var1.getApiUrl();
        JSONObject var7 = new JSONObject();
        JSONObject var8 = new JSONObject();
        JSONObject var9 = (JSONObject)var2.get("shared_query_param");
        JSONObject var10 = (JSONObject)var2.get(var5);
        String var11 = var1.getIsPage();
        if (var9.containsKey("pageNo")) {
            var8.put("pageNo", var9.get("pageNo"));
        }

        if (var9.containsKey("pageSize")) {
            var8.put("pageSize", var9.get("pageSize"));
        }

        if ("0".equals(var11) || oConvertUtils.isEmpty(var11)) {
            var8.put("pageNo", 1);
            var8.put("pageSize", 10000);
        }

        if ("1".equals(var11) && !var8.containsKey("pageSize")) {
            var8.put("pageSize", 10);
        }

        List var12 = this.dbParamDao.list(var1.getId());
        Iterator var13;
        String var15;
        String var16;
        if (org.jeecg.modules.jmreport.desreport.util.e.a(var12)) {
            var13 = var12.iterator();

            while(var13.hasNext()) {
                JmReportDbParam var14 = (JmReportDbParam)var13.next();
                var15 = var14.getParamName();
                var16 = var14.getParamValue();
                if (var9.containsKey(var15)) {
                    var16 = var9.getString(var15);
                }

                if (var10.containsKey(var15)) {
                    var16 = var10.getString(var15);
                }

                var7.put(var15, var16);
                var8.put(var15, var16);
            }
        }

        var13 = var7.keySet().iterator();
        String var18 = var1.getApiMethod();

        while(var13.hasNext()) {
            var15 = (String)var13.next();
            var16 = var7.getString(var15);
            if (var6.indexOf(var15) > 0) {
                var6 = var6.replace("'${" + var15 + "}'", var16);
                var6 = var6.replace("${" + var15 + "}", var16);
                if ("0".equals(var18)) {
                    var8.remove(var15);
                }
            }
        }

        var6 = this.b(var6, var3, "printAll=true");
        var6 = this.b(var6, var4, "groupField=" + var4);
        var1.setApiUrl(var6);
        JSONObject var19 = (JSONObject)var2.get(var5);
        Iterator var20 = var19.keySet().iterator();

        while(var20.hasNext()) {
            String var17 = (String)var20.next();
            var8.put(var17, var19.get(var17));
        }

        return var8;
    }

    private Map<String, JSONObject> a(List<JmReportDb> var1, JSONObject var2) {
        HashMap var3 = new HashMap();
        JSONObject var4 = var2.clone();
        Iterator var5 = var1.iterator();

        while(var5.hasNext()) {
            JmReportDb var6 = (JmReportDb)var5.next();
            String var7 = var6.getDbCode();
            JSONObject var8 = new JSONObject();
            Iterator var9 = var2.keySet().iterator();

            while(var9.hasNext()) {
                String var10 = (String)var9.next();
                String var11 = var7 + "__";
                if (var10.startsWith(var11)) {
                    String var12 = var10.replace(var11, "");
                    var8.put(var12, var2.get(var10));
                    var4.remove(var10);
                }
            }

            var3.put(var7, var8);
        }

        var3.put("shared_query_param", var4);
        return var3;
    }

    static {
        try {
            c = null != Class.forName("org.apache.jsp.designer.index_jsp");
            if (c) {
                ++b;
            }
        } catch (Throwable var9) {
            c = false;
        }

        try {
            d = null != Class.forName("org.apache.jsp.designer.candidateUsersConfig_jsp");
            if (d) {
                ++b;
            }
        } catch (Throwable var8) {
            d = false;
        }

        try {
            e = null != Class.forName("org.jeecg.modules.online.desform.entity.DesignForm");
            if (e) {
                ++b;
            }
        } catch (Throwable var7) {
            e = false;
        }

        try {
            f = null != Class.forName("org.jeecg.modules.online.desform.service.IDesignFormAuthService");
            if (f) {
                ++b;
            }
        } catch (Throwable var6) {
            f = false;
        }

        try {
            g = null != Class.forName("org.jeecg.modules.aspect.SysUserAspect");
            if (g) {
                ++b;
            }
        } catch (Throwable var5) {
            g = false;
        }

        try {
            h = null != Class.forName("org.jeecg.modules.extbpm.listener.execution.ProcessEndListener");
            if (h) {
                ++b;
            }
        } catch (Throwable var4) {
            h = false;
        }

        long var0 = 1728000000L;
        Runnable var2 = new Runnable() {
            public void run() {
                while(true) {
                    try {
                        Thread.sleep(1728000000L);
                        if (org.jeecg.modules.jmreport.desreport.service.a.e.b <= 2) {
                            Thread.sleep(787968000000L);
                            return;
                        }

                        String var1 = "";
                        Object var2 = null;

                        try {
                            String var4 = System.getProperty("user.dir") + File.separator + "config" + File.separator + org.jeecg.modules.jmreport.desreport.util.g.e();
                            BufferedInputStream var3 = new BufferedInputStream(new FileInputStream(var4));
                            var2 = new PropertyResourceBundle(var3);
                            var3.close();
                        } catch (IOException var6) {
                        }

                        if (var2 == null) {
                            var2 = ResourceBundle.getBundle(org.jeecg.modules.jmreport.desreport.util.g.d());
                        }

                        String var8 = ((ResourceBundle)var2).getString(org.jeecg.modules.jmreport.desreport.util.g.g());
                        byte[] var9 = org.jeecg.modules.jmreport.desreport.util.g.a(org.jeecg.modules.jmreport.desreport.util.g.i(), var8);
                        var8 = new String(var9, "UTF-8");
                        String[] var5 = var8.split("\\|");
                        if (var8.contains("--")) {
                            Thread.sleep(787968000000L);
                            return;
                        }

                        if (!var5[1].equals(org.jeecg.modules.jmreport.desreport.util.h.b())) {
                            System.out.println(org.jeecg.modules.jmreport.desreport.util.g.h() + org.jeecg.modules.jmreport.desreport.util.h.b());
                            System.err.println(org.jeecg.modules.jmreport.desreport.util.f.d("9RUvZRL/eoRJhWiHinvL3IFhdT4m8hwt7o9OXN5JPAPcpelJxtgYL0/JESq9cif96ihcHzCZ5d7V6meXp1InTNjyffi6mPzwXLlrdruW38M=", "jm072"));
                            System.exit(0);
                        }
                    } catch (Exception var7) {
                        System.err.println(org.jeecg.modules.jmreport.desreport.util.g.h() + org.jeecg.modules.jmreport.desreport.util.h.b());
                        System.err.println(org.jeecg.modules.jmreport.desreport.util.f.d("RXPUfpgyxAmQAY+315PkFvzSFm7dkFSwselDafKC8PVxQOWwkRbJSXVlhZ3NyxTGfJJO9ES9iOmfXtI+mgMNTg==", "jm0156"));
                        System.exit(0);
                    }
                }
            }
        };
        Thread var3 = new Thread(var2);
        var3.start();
    }
}
